Solved

HTTP Post keep alive and chunked

Posted on 2013-06-17
3
620 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 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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 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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now