HTTP image download

I am having troubles handling HTTP response from an IPcamera.

The request:

WebClient.GetFromWeb("").ResponseReceived += new HttpRequest.ResponseHandler(Program_ResponseReceived);
void Program_ResponseReceived(HttpRequest sender, HttpResponse response)
var dataStream = new StreamReader(response.Stream);            
var headers = response.GetWebHeaderCollection();
var ContentLength = headers.GetValues("Content-Length")[0];
var buffer = response.RawContentBytes;

Now, this works ‘fine’ if the image is smaller than 4kB (4096 bytes), I need a way to handle larger files. (Up to about 30kB)

It apears that the HTTP read buffer is limited to 4kB - I have no problem reading up to 4KB at a time, I but know how to catch following packets.
Reading from the input stream limits me to 4kB aswell…

The Framework seems to truncate some ‘important’ information:
HTTP headers sent:
Content-Length: 12345 (allways 5 digits, leading with 0)
Content-Type: image/jpeg
HTTP headers received:
Content-Length: 1234
Content-Type: image/jpe

This means I am unable to know the exact content-Length. Guess multiplying the received with 10 and adding 10 bytes would be sufficient. Is this a framework problem or is there other things at play here? The network packages seems fine on my PC.

You could do a looped read while the available data on response is greater than 0.

Thank you for your quick reply.

If I try to do a looping read, I do nothing but duplicate the data.

If I use a StreamReader to access the response stream, the stream is empty / endOfStream.

Accessing the stream directly gives me duplicate data, flush(), close(), dispose() commands have no effect at all.

Accessing RawContentBytes gives duplicate data aswell.