?
Solved

HTTP Post keep alive and chunked

Posted on 2013-06-17
3
Medium Priority
?
829 Views
Last Modified: 2013-06-18
In Visual Basic ....VB.Net, or Windows Service whatever...
I need to post some XML using the following setup

Instructions: "HTTP chunked encoding includes the header "Transfer-Encoding:chunked " and the length of the chunk (plus newline) before actual chunk"

POST /bot1/bot1 HTTP/1.1
Host:  costed.theConnNet.com
Connection:  keep-alive
Content-Type: text/plain
Transfer-Encoding: chunked

Lets say for example I need to post this
<root>
   <clientID> 123</clientID>
   <inStat>Yes></inStat>
<root>

I have this so far...but not sure what to do with the code between the ======= marks and how to implement the
"length of chunk plus new line"  part

 Public Sub GetXmlChunkedData(ByVal URI As String, ByVal Parameters As String)
        Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(URI)

        Dim request As HttpWebRequest
        Dim response As HttpWebResponse = Nothing

        Try
            ' Create the web request   
            request = DirectCast(WebRequest.Create(URI), HttpWebRequest)
            request.ContentType = "text/plain"
            request.Method = "POST"
            request.KeepAlive = True
            request.TransferEncoding = "chunked"
            request.UserAgent = "CometTest"

            '===========================================================================
            'Dim bytes As Byte() = System.Text.Encoding.ASCII.GetBytes(Parameters)
            'request.ContentLength = bytes.Length
            'Dim os As System.IO.Stream = request.GetRequestStream()
            'os.Write(bytes, 0, bytes.Length)
            'os.Close()

            '' Get response   
            'response = DirectCast(request.GetResponse(), HttpWebResponse)

            '' Load data somewhere
            '============================================================================

        Finally
            If Not response Is Nothing Then response.Close()
        End Try

    End Sub

Open in new window

0
Comment
Question by:lrbrister
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 total points
ID: 39255020
Each chunk starts with the number of octets of the data it embeds expressed in hexadecimal followed by optional parameters (chunk extension) and a terminating CRLF (carriage return and line feed) sequence, followed by the chunk data. The last chunk is a zero-length chunk, with the chunk size coded as 0, but without any chunk data section.

http://blogs.msdn.com/b/asiatech/archive/2011/04/26/how-to-write-chunked-transfer-encoding-web-response.aspx
0
 

Author Comment

by:lrbrister
ID: 39256042
ve3ofa,

Ok...I recognized the vowels and consonets.

But little else in your answer.  

I need to do this in Visual Basic. You have a different link?
0
 

Author Closing Comment

by:lrbrister
ID: 39257487
I wasn;t clear enough.
This gives me the information, but in a different environment
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question