hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Preemptive Basic auth not working?
Date Tue, 06 Sep 2011 21:36:38 GMT
On Tue, 2011-09-06 at 14:29 -0700, Patrick Lightbody wrote:
> I read the docs + examples for preemptive basic auth, but it still doesn't look to be
working. I started debugging the code and I'm actually not sure how it could work. Please
let me know if I'm misunderstanding how the internals of HttpClient works, but here's what
I observed:
> 
>  * RequestTargetAuthentication is responsible for adding the auth headers
>  * RequestTargetAuthentication looks for an AuthState object that has non-null scheme
& creds objects that are used for the header
>  * DefaultRequestDirector creates an empty AuthState object on each new request (targetAuthState
field)
>  * DefaultRequestDirector only updates the targetAuthState fields after it makes an initial
request that returns a 401
> 
> So what I'm finding in my debugging is that even though I've set up my CredentialsProvider
with the correct authScope + UsernamePasswordCredentials and that I've set my HttpContext
(global or local, doesn't matter) with the proper AuthCache + BasicScheme, I still end up
with two queries: 401 and then finally a 200.  In other words, it doesn't seem to be preemptive.
> 
> Any idea what I might be doing wrong? Or maybe I'm just misunderstanding how DefaultRequestDirector
does it's loop inside execute()?
> 
> Patrick
> 


If you turn of context logging you should be able to see whether or not
the cached auth scheme is being re-used.

Oleg


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


Mime
View raw message