hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Lightbody <patr...@lightbody.net>
Subject Preemptive Basic auth not working?
Date Tue, 06 Sep 2011 21:29:33 GMT
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





Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message