How to find the length of network streams which do not support see

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a network stream which I got from HttpWebResponse and does not support
seeking, How do I find the length of the network stream?

HttpWebResponse* response = dynamic_cast<HttpWebResponse*>
(request->GetResponse());

// Gets the stream associated with the response.
Stream* receiveStream = response->GetResponseStream();

int n = receiveStream->Read(responseArray, 0, responseString->Length);
 
Sorry. Correct some typos.
------------------------------------
I have a network stream which I got from HttpWebResponse and does not support
seeking, How do I find the length of the network stream?

HttpWebResponse* response = dynamic_cast<HttpWebResponse*>
(request->GetResponse());

// Gets the stream associated with the response.
Stream* receiveStream = response->GetResponseStream();

int n = receiveStream->Read(responseArray, 0, receiveStream->Length);
 
Kueishiong said:
Sorry. Correct some typos.


since it's a stream I'd assume you can't get the length. You just read
(eg in a while loop) until Read() returns 0. Of course you can put
everything is some kind of an dynamic buffer and keep track of the
amount of data recieved yourself.

Alternatively you could look at the property ContentLength, however I'm
not certain that this is reliable enought as a WebServer might not emit
this http-header. Don't know how common if at all this is.
 
Back
Top