How to: Work with System.Net.ChunkedReadStream?

  • Thread starter Thread starter Topper
  • Start date Start date
T

Topper

Hello all

I have a WebResponse object and its GetResponseStream() returnes a
System.Net.ChunkedReadStream.
This stream is readeable (CanRead = true) but i cann't readByte() -
exception occured: "The chunk length was not valid." but response is not
empty - i know.

How can i work with ChunkedReadStream?

Thanx.
 
Can you clarify what you mean by "cant readByte()"? Are you trying to read
byte-by-byte, as in...

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(...);
....
HttpWebResponse resp = req.GetResponse() as HttpWebResponse;

Stream rs = resp.GetResponseStream();

int offset = 0;
byte [] buffer = new byte[1024];
int read = -1;

try {
read = rs.Read(buffer,offset,1);
while(read > 0) {
++ offset;
read = rs.Read(buffer,offset,1);
}
} catch(..) {
} finally {
rs.Close();
resp.Close();
}


IF you are getting an exception, can you list the exact exception message
and stack trace?
 
Back
Top