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

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);
 
G

Guest

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);
 
B

Ben Schwehn

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.
 

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

Top