Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

HttpWebRequest

I feel stupid for asking...

Is there any way to do a "phased POST" on an HttpWebRequest?

In my code below
Without opening another connection
can the Dim newStream As Stream = sendWebRequest.GetRequestStream() be done in pieces?

Here's my code that works.
Dim sendWebRequest As HttpWebRequest = CType(WebRequest.Create(stUrl), HttpWebRequest)

'Following items 
 sendWebRequest.SendChunked = True
sendWebRequest.Method = "POST"
sendWebRequest.ContentType = "text/plain"
sendWebRequest.KeepAlive = True
sendWebRequest.UserAgent = "CometTest"
sendWebRequest.ServicePoint.ConnectionLimit = 20
sendWebRequest.Timeout = 43200


Dim encodedData As New ASCIIEncoding()
Dim byteArray As Byte() = encodedData.GetBytes(sendRow)

sendWebRequest.ContentLength = byteArray.Length

Dim newStream As Stream = sendWebRequest.GetRequestStream()
newStream.Write(byteArray, 0, byteArray.Length)
newStream.Close()

Open in new window

Avatar of lenordiste
lenordiste
Flag of France image

what is supposed to be a "phased POST" for you? if you are looking for the asynchronous way of handling this, here is a start:
http://msdn.microsoft.com/en-us/library/system.net.webrequest.getrequeststreamasync.aspx

if not, what are you trying to accomplish :) ?
Avatar of Larry Brister

ASKER

I have a POST of XML I'm sending to the HttpWebRequest
It looks like
<command><id>1</id></command>
<command><id>2</id></command>
<command><id>3</id></command>
<command><id>4</id></command>
<command><id>5</id></command>
<command><id>6</id></command>
<command><id>7</id></command>
<command><id>8</id></command>

So I want to "Open a Post???"
send first 4
pause 1000 milli seconds with a sleep
send the other 4
Complete the post.

I THINK this is a dumb question...
Just not experienced enough with the POST part to know.
Avatar of David Johnson, CD
After you've done the first post would not the server then think that you've finished and not know what to do with the remaining posts?
ve3ofa

That's what I keep trying to say.

As I mentioned above..
This is not my area of expertise.

So that's why I'm asking if there is a "threaded" post
the only thing that comes to mind is the http keep-alive which is turned on by default and allows http requests to reuse TCP connections. Codewise there's no really such thing as to "open a post". That being said, why don't you use more than one xml command in a single post?
lenordiste

Not sure that would work

In my list above I'm currently posting 4 at a time in separate threaded posts.

On the VENDOR end...
They only allow (x) numbers in the "waiting" status on the post at a time.

In any event...
How could I send more that one xml command at a time?
ASKER CERTIFIED SOLUTION
Avatar of lenordiste
lenordiste
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks