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! >
Brian, 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 Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
