Hi Oleg thanks for the answers there are helpful :) how can I set the proxy per request?
thanks stelios On 5 January 2011 16:51, Oleg Kalnichevski <[email protected]> wrote: > On Wed, 2011-01-05 at 13:33 +0100, Stelios Togias wrote: > > Hi, > > > > Not sure how to phrase this... > > > > 1) Is creating a new instance of HttpClient a costly operation? > > No, it is not, but creating a new instance of a connection manager is. > > > 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? > > > > Re-using the same instance of HttpClient per logical HTTP service is > strongly recommended. > > > > 2) To correctly release resources I use > > "response.getEntity().consumeContent();". First, is this the preferred > way? > > It is merely a convenience method. The general rule is very simple: one > MUST close the input stream obtained from HttpEntity in order to free > all resources allocated by that entity. > > > 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();" > > > > Same as above. Just make sure the input stream gets closed when no > longer needed. > > > 3) Is there a way to set proxy on/off. From what I've seen using a proxy > > needs different instantiation of the HttpClient. > > Absolutely. Proxy can be set on a per request level. > > > 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. > > > > Hope this helps > > Oleg > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
