hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Lightbody <patr...@lightbody.net>
Subject Re: Preemptive Basic auth not working?
Date Tue, 06 Sep 2011 22:06:44 GMT
Oleg,
Thanks for the quick reply. One question: Is that an API call, or simply turning on low-level
log statements for the BasicHttpContext class via commons-logging?

Patrick

On Sep 6, 2011, at 2:36 PM, Oleg Kalnichevski wrote:

> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message