multipart message from WebRequest (asynchronous)

G

Guest

How do you retrieve the streaming 'parts' of a multipart message from a
WebRequest?

Here is the situation.

A WebRequest is submitted to a server (http://TheServer:80/GetMedia?ID=1).
This causes the server to push/stream a multipart message back to the client
in the following format:

HTTP/1.1 200 OK
Date: Fri, 24 Feb 2006 12:01:31 CST
Server: MyServer/1.0
Content-type: multipart/x-mixed-replace;boundary=Separator

--Separator
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-Length: 11346

<binary data>

--Separator
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-Length: 11346

<binary data>

--Separator--

In the callback for BeginGetResponse, the get response I get the response
from the EndGetReponse method. The response stream contains the first 'part'
(everything between the first and second '--Separator', ie both the headers
and binary data). How do I get the rest of the message parts?
 
J

Joerg Jooss

Thus wrote KReichert,
How do you retrieve the streaming 'parts' of a multipart message from
a WebRequest?

Here is the situation.

A WebRequest is submitted to a server
(http://TheServer:80/GetMedia?ID=1). This causes the server to
push/stream a multipart message back to the client in the following
format:

HTTP/1.1 200 OK
Date: Fri, 24 Feb 2006 12:01:31 CST
Server: MyServer/1.0
Content-type: multipart/x-mixed-replace;boundary=Separator
--Separator
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-Length: 11346
<binary data>

--Separator
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-Length: 11346
<binary data>

--Separator--

In the callback for BeginGetResponse, the get response I get the
response from the EndGetReponse method. The response stream contains
the first 'part' (everything between the first and second
'--Separator', ie both the headers and binary data). How do I get the
rest of the message parts?

The response stream is just that -- a stream of bytes. It has no notion of
parts. You have to make sure that you read all bytes from the response stream
before continuing higher level processing such as parsing parts.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top