hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Boudnik <...@apache.org>
Subject Forcefully closing ContentLengthInputStream: is it possible?
Date Tue, 04 Oct 2011 22:52:13 GMT
Hello

Firstly, I'd like to thank this group of people for outstanding job in
development Java layer for generic HTTP: very nicely and conveniently done!

Now, once I am done with being nice I have a question ;) Here's the use case
where I don't see a good workaround for.

We have that piece of functionality in our app. where we need to grab a little
sample of a web.object (e.g. a file somewhere on a web-server side). Once the
sample is obtained the software isn't interested in the rest of the content
and would like to close the InputStream (actually it happens to be
ContentLengthInputStream) from that object. The situation we are in is that we
can't set ContentLength on the client side and the connection is forcefully
kept alive from the server side.

The objects (files) are pretty large (10s or 100s of Mb) and we don't want to
keep downloading the rest of the content every time we need to sample. By
looking into the code of that class above I see that close() method keeps
pumping the data until ContentLength is reached. This seems to be troublesome
in cases when the app's code is rapidly opens a whole bunch of connections to
different remote objects for the sampling purposes and then trying to close
those. However, close() doesn't do any real closing of the socket input so
data transfer continues and I might end up with OOME ;(

Considering above restrictions is their any advisable solution for the problem
I am facing? I believe patching ContentLengthInputStream might be pretty
tricky because ContentLengthInputStream can't actually close SessionInputBuffer.

Any hints would be highly appreciated!
-- 
Thanks in advance,
	Cos


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


Mime
View raw message