hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ole Matzura <...@eviware.com>
Subject Re: problems with cached credentials
Date Mon, 26 Sep 2005 22:11:33 GMT
ah! learn from the masters!

thanks!

/Ole

Oleg Kalnichevski wrote:

>On Mon, 2005-09-26 at 23:38 +0200, Ole Matzura wrote:
>  
>
>>Hi!
>>
>>newbie problem coming up; I'm using HttpClient with the 
>>MultiThreadedHttpConnectionManager in a MT environment where I have my 
>>own CredentialsProvider set up for providing credentials on 
>>authentication challenges.
>>
>>HttpClient seems to internally cache the credentials returned by my 
>>provider which is a problem in my case since I want to provide different 
>>credentials for different requests to the same host..
>>
>>my current work-around is to instantiate a new HttpClient for each 
>>request, which seems a bit "harsh".. is there any way of clearing some 
>>internal "credentials cache"?
>>    
>>
>
>HttpState#clear() is what you want. 
>
>httpclient.getState().clear();
>
>Alternatively you may want to create a new HttpState instance per
>request / session
>
>// shared by several threads
>MultiThreadedHttpConnectionManager mtcm = new
>MultiThreadedHttpConnectionManager();
>HttpClient httpclient =  new HttpClient(mtcm);
>
>// per thread / host / session / request
>HttpState state = new HttpState();
>HostConfiguration hostconf = new HostConfiguration();
>hostconf.setHost("targethost");
>GetMethod httpget = new GetMethod("/stuff");
>httpclient.executeMethod(hostconf, httpget, state);
>
>Hope this helps
>
>Oleg
>
>  
>
>>hope this is understandable.. thanks for any help!
>>
>>regards,
>>Ole
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>
>  
>



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


Mime
View raw message