Marek Lewczuk wrote:
Darin Fisher napisał(a):
Thanks for reply. So what should I do ? Is there any other solution to download (synchronously) file from HTTP ?
The stream returned by nsIChannel::open implements blocking i/o, but under the hood the data is being buffered as it arrives. So, at first there is no data available in the stream, then as more data arrives the amount available in the buffer increases. In this particular example, the stream actually blocks until it can report a non-zero amount available or some error occurs. You cannot use available as a measure of the total stream length. For that you should use nsIChannel::contentLength, but that is often -1 (for HTTP chunked data) or the wrong number (for HTTP content encoded data).
ML
What you're doing is fine. Just sit in a loop and call read a bunch of times until read returns 0 bytes read. Then you know you have reached EOF. You likely don't even have to call available.
-Darin _______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
