However, when the response is being sent with Transfer-Encoding =
Chunked, this technique appears to break. When my stream appears to
be exhausted, I have nothing but headers, no "payload".
I have tried, when the first stream is exhausted, using another
"BeginGetResponse" if the headers indicate chunking. No dice. I've
also attempted to get another stream after closing the first. Not
happening.
I've searched everywhere for example code that does this and handles
chunking, and so far, no success.
Please let me know if you think there's a better place to ask this
question, also.
Bob
>
> I have written a class that will asynchronously read the response
> stream from an httpwebrequest. It uses the Stream.BeginRead method
> inside my EndGetResponse callback function, and my Stream.EndRead
> callback function will use BeginRead again until the EndRead callback
> results in zero bytes read. Works great, and it should, since I
> borrowed the framework from an example found in MSDN somewhere.
>
> However, when the response is being sent with Transfer-Encoding =
> Chunked, this technique appears to break. When my stream appears to
> be exhausted, I have nothing but headers, no "payload".
>
> I have tried, when the first stream is exhausted, using another
> "BeginGetResponse" if the headers indicate chunking. No dice. I've
> also attempted to get another stream after closing the first. Not
> happening. [...]
You should probably post a concise-but-complete code example that reliably
demonstrates the problem.
I haven't found anything definitive, but a variety of sources, including
MSDN, imply to me that HttpWebRequest/Response automatically handles
chunked transfers on your behalf. It may simply be an error in your own
code, or a misunderstanding of how to use the class. Without a proper
code example, there's no way to comment on it.
Pete
Hi, Pete - I appreciate the rapid response. I can't really post the
code without some clean-up and sanitizing, but if that's what it will
take, I'll do that. It's really fundamentally the same code that can
be found in multiple threads in this very newsgroup, easiily found by
searching for BeginGetResponse. I was really hoping to find someone
who had done this, ran into the same problem, and would share their
solution. One of the problems a good samaritan like yourself will run
into, even with my code in hand, is finding a source of chunked
responses against which you can test.
To be continued...
Bob
> [...] One of the problems a good samaritan like yourself will run
> into, even with my code in hand, is finding a source of chunked
> responses against which you can test.
Indeed. It's one of the reasons it's so important for the questioner
(you) to provide a complete, self-contained code example. Another person
could invest (and potentially waste) a great deal of time trying to even
reproduce the exact problem you're seeing.
Pete