hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 27366] - GetMethod.getResponseBodyAsStream() .available() could return content-length
Date Tue, 09 Mar 2004 08:51:32 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=27366>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=27366

GetMethod.getResponseBodyAsStream() .available() could return content-length





------- Additional Comments From ortwin.glueck@nose.ch  2004-03-09 08:51 -------
George,

Even Gossling can write sub-optimal code. We all know there is some very bad
code in the Java Standard API :-) InputStream::available() is clearly documented
as "Returns the number of bytes that can be read (or skipped over) from this
input stream without blocking by the next caller of a method for this input
stream." Not following this contract is one bad thing. The user relying on us to
follow a different contract than the original method is even worse.
Also the nature of a stream allows for an infinite stream of data. I guess that
this was the reason that the Java API provides no way of figuring out the length
of a stream. And it is the same reason for us to provide this completely
optional piece of information with a supplementary method called
getResponseContentLength(). It can even return -1 if the content length is unknown.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message