Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

HTTP Post keep alive and chunked

Posted on 2013-06-17
3
Medium Priority
?
793 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 83

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

636 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