Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(489)

Issue 51004: Respect cookies set in a 401 responses when restarting the http transaction.... (Closed)

Created:
11 years, 9 months ago by eroman
Modified:
9 years, 6 months ago
Reviewers:
wtc
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

Respect cookies set in a 401 responses when restarting the http transaction. There are two parts to this change: (1) rebuild the request cookies before each transaction restart for authentication (2) notify the URLRequestHttpJob of header completion before *each* transaction restart for authentication By "each transaction" I mean the automatic restarts that don't require user input, such as: - replying to the first step of NTLM - selecting identity embedded in URL - selecting identity in auth-cache Needing to notify URLRequestHttpJob for these intermediate restarts is a consequence of cookie store management being done outside of HttpNetworkTransaction. After updating the cookie store, URLRequestHttpJob now tests |HttpTransaction::IsReadyToRestartForAuth()| to check whether the notification was informational or an identity is actually needed. R=wtc BUG=6450 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=12635

Patch Set 1 #

Total comments: 3

Patch Set 2 : add back proxy_auth_state_, server_auth_state_, which is depended by ui tests #

Total comments: 22

Patch Set 3 : Address wtc comments #

Total comments: 2

Patch Set 4 : Do a gclient sync to update files #

Total comments: 8

Patch Set 5 : Address wtc's comments #

Patch Set 6 : address rest of wtc's comments (had missed some in previous patchset) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+296 lines, -77 lines) Patch
M net/http/http_auth.h View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
M net/http/http_cache.cc View 1 2 3 2 chunks +7 lines, -0 lines 0 comments Download
M net/http/http_network_transaction.h View 1 2 3 4 chunks +12 lines, -8 lines 0 comments Download
M net/http/http_network_transaction.cc View 1 2 3 6 chunks +27 lines, -26 lines 0 comments Download
M net/http/http_network_transaction_unittest.cc View 1 2 3 4 12 chunks +63 lines, -15 lines 0 comments Download
M net/http/http_transaction.h View 1 2 3 1 chunk +8 lines, -0 lines 0 comments Download
M net/http/http_transaction_unittest.h View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M net/http/http_util.h View 1 2 3 1 chunk +8 lines, -0 lines 0 comments Download
M net/http/http_util.cc View 1 2 3 1 chunk +25 lines, -0 lines 0 comments Download
M net/http/http_util_unittest.cc View 1 2 3 1 chunk +23 lines, -0 lines 0 comments Download
M net/tools/testserver/testserver.py View 3 4 5 3 chunks +5 lines, -0 lines 0 comments Download
M net/url_request/url_request.cc View 1 2 3 1 chunk +2 lines, -20 lines 0 comments Download
M net/url_request/url_request_http_job.h View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M net/url_request/url_request_http_job.cc View 1 2 3 4 chunks +43 lines, -8 lines 0 comments Download
M net/url_request/url_request_unittest.cc View 3 4 5 3 chunks +62 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
eroman
There is still a unit-test I want to add to this CL; will update with ...
11 years, 9 months ago (2009-03-21 23:53:41 UTC) #1
wtc
LGTM. The solution seems ad hoc, created specifically to address the 401 set-cookie issue. But ...
11 years, 9 months ago (2009-03-23 23:14:31 UTC) #2
wtc
http://codereview.chromium.org/51004/diff/1/12 File net/url_request/url_request_http_job.cc (left): http://codereview.chromium.org/51004/diff/1/12#oldcode58 Line 58: proxy_auth_state_(net::AUTH_STATE_DONT_NEED_AUTH), On 2009/03/21 23:53:41, eroman wrote: > I ...
11 years, 9 months ago (2009-03-23 23:17:38 UTC) #3
eroman
> This change is not in Patch Set 2, which I reviewed. > Should I ...
11 years, 9 months ago (2009-03-24 23:29:54 UTC) #4
wtc
LGTM. Nice work! http://codereview.chromium.org/51004/diff/3001/4003 File net/http/http_cache.cc (right): http://codereview.chromium.org/51004/diff/3001/4003#newcode439 Line 439: if (!network_trans_.get()) On 2009/03/24 23:29:54, ...
11 years, 9 months ago (2009-03-25 17:55:53 UTC) #5
eroman
11 years, 9 months ago (2009-03-26 00:42:42 UTC) #6
http://codereview.chromium.org/51004/diff/3001/4003
File net/http/http_cache.cc (right):

http://codereview.chromium.org/51004/diff/3001/4003#newcode439
Line 439: if (!network_trans_.get())
On 2009/03/25 17:55:53, wtc wrote:
> On 2009/03/24 23:29:54, eroman wrote:
> >
> > network_trans_ may be NULL if it was reset after getting a 304 response.
> 
> I see.  I guess we either need this null check here, or
> we need to protect the IsReadyToRestartAuth() call in
> URLRequestHttpJob by checking that the response code is
> 401 or 407.
> 
> 

I will leave this as-is for now.

(trying to consolidate the 401/407 checks into just HttpNetworkTransaction).

http://codereview.chromium.org/51004/diff/4014/3009
File net/http/http_network_transaction_unittest.cc (right):

http://codereview.chromium.org/51004/diff/4014/3009#newcode1615
Line 1615: // After automatically restarting with a null identity, this is the
On 2009/03/25 17:55:54, wtc wrote:
> Nit: We should remove "automatically" from this comment, and
> the same comment in the next unit test.  Now
> HttpNetworkTransaction no longer automatically restarts
> itself; it is restarted (automatically) by
> URLRequestHttpJob.

Done.
Good catch!

http://codereview.chromium.org/51004/diff/4017/4032
File net/url_request/url_request_unittest.cc (right):

http://codereview.chromium.org/51004/diff/4017/4032#newcode938
Line 938: // Check that cookie headers in 401 responses are respected.
On 2009/03/25 17:55:54, wtc wrote:
> Nit: Set-Cookie headers

Done.

http://codereview.chromium.org/51004/diff/4017/4032#newcode946
Line 946: server->TestServerPage("auth-basic?setCookieIfChallenged");
On 2009/03/25 17:55:54, wtc wrote:
> Nit: we seem to use dashes (-) instead of camelCaps in
> the TestServerPage URLs.

Done.

http://codereview.chromium.org/51004/diff/4017/4032#newcode970
Line 970: // (without user intervention).
On 2009/03/25 17:55:54, wtc wrote:
> You may want to point out this is because identity is
> embedded in the URL.

Done.

> Why isn't the HTTP auth cache being used?  Is it because
> the two URLRequests don't share the same URLRequestContext?

Correct. I put them in their own scopes to keep the cases separate.

http://codereview.chromium.org/51004/diff/4017/4032#newcode976
Line 976: std::string username("victoria");
On 2009/03/25 17:55:54, wtc wrote:
> Is this another test to see if I am really reviewing?

what?! ... its legit :)

Ok, changed to "user2".

(Note, I want to use a different username from the earlier test just to make it
harder for the test to get messed up from earlier state and pass when it should
be failing).

Powered by Google App Engine
This is Rietveld 408576698