hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stelios Togias <stetog...@gmail.com>
Subject Correct usage (instantiation of httpClient, proxy, resource releasing)
Date Wed, 05 Jan 2011 12:33:48 GMT

Not sure how to phrase this...

1) Is creating a new instance of HttpClient a costly operation? Meaning is
it ok to create a new instance
each time I need to use httpClient or the typical usage is to create one
object and use it throughout the application lifecycle?

2) To correctly release resources I use
"response.getEntity().consumeContent();". First, is this the preferred way?
Second, when  I get the response as an InputStream that is consumed later in
the application,
using consumeContent will cause the stream to be closed and the client
cannot then consume the stream.
Will the resources be released automatically in this case or do I need some
kind of callback to manually call "response.getEntity().consumeContent();"

3) Is there a way to set proxy on/off. From what I've seen using a proxy
needs different instantiation of the HttpClient.
So I cannot have one instance and somehow attach a proxy object, or set the
proxy to true/false. Is there some way to do this
or I just need to have a separate instance in the case I need to use proxy.

Some of the questions might seem ambiguous since I just started using
httpClient...I can describe better my use case if needed.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message