hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: HttpClient and Web App Credentials
Date Tue, 14 Oct 2008 21:46:13 GMT
On Tue, 2008-10-14 at 10:50 -0700, Brian Tanner wrote:
> I'm torn!  I'm using HttpClient in a Web application which uses the
> authentication information from the Web app login to set credentials in the
> HttpClient.  I see that getState() is synchronized, but if I’m only using
> one instance of the HttpClient in my web app, I could potentially send a
> request to the back-end web server using credentials from a different user
> session.
> I have a choice to make, I’m not sure which is best:
>     o  I could create a synchronized block on the HttpClient instance that I
> fetch from my singleton class and set the credentials and execute the
> request in the same block.
>     o  I can setup the HttpClient with the credentials using
> .getState().setCredentials and then store the client in the session of the
> web app.  Problem is HttpClient does not implement serializable and my
> environment is clustered.
>     o  I can create a new instance of HttpClient for every call to the
> backend web server – blah!
> Help!


It is all very simple. Just use a separate instance of HttpState per
individual thread of execution and pass it as a parameter to the
HttpClient#execute method.

Hope this helps


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

View raw message