hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Kohlschuetter ...@rrzn.uni-hannover.de>
Subject Re: Proposal: Configurable HTTP Response length limit
Date Sat, 11 Oct 2003 10:14:13 GMT
Am Freitag, 10. Oktober 2003 18:56 schrieb Eric Johnson:
> (...) If we took
> your suggestion and simply stopped reading the stream sent by the
> server, when processing the _next_ request on the same socket, we'd run
> into lots of problems.


I think this is the problem of my workaround, which I now understand.

You will agree that it would be better to throw an IOException (EOFException) 
in case of unexpected EOFs (from the view of HTTPClient.class) instead of 
just returning a "regular EOF" (-1). I have modified my solution to do so.

Before sending a patch, I will try to explain my idea.

As far as I understand, in HttpMethodBase.readResponseBody, an 
AutoCloseInputStream is created, which wraps around the inner InputStreams 
(ChunkedInputStream, eventually LimitSizeInputStream and SocketInputStream).

The AutoCloseInputStream calls a ResponseConsumedWatcher defined in 
HttpMethodBase itself - right after the stream was consumed to be able to 
reuse the connection.

In case that LimitSizeInputStream throws an EOFException because the limit is 
reached, this EOFException will be thrown up to the AutoCloseInputStream.

Instead of just throwing it again, a "readErrors" flag is set and thrown right 
after that to the caller.

When notifyWatcher() is called next time, it will call 
watcher.responseConsumed with readErrors as parameter.

HTTPMethod's ResponseConsumedWatcher then calls 
responseBodyConsumed(readErrors), where we now can decide whether to close 
the underlying Connection or release it for further processing. If readErrors 
== true, then the connection will definitely be closed.

Would you accept such a solution?


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

View raw message