Index: net/url_request/url_request_unittest.cc |
=================================================================== |
--- net/url_request/url_request_unittest.cc (revision 138297) |
+++ net/url_request/url_request_unittest.cc (working copy) |
@@ -2884,6 +2884,37 @@ |
EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
!= std::string::npos); |
} |
+ |
+ // Same test as above, except this time the restart is initiated earlier |
+ // (without user intervention since identity is embedded in the URL). |
+ { |
+ TestNetworkDelegate network_delegate; // must outlive URLRequest |
+ scoped_refptr<TestURLRequestContext> context( |
+ new TestURLRequestContext(true)); |
+ context->set_network_delegate(&network_delegate); |
+ context->Init(); |
+ |
+ TestDelegate d; |
+ |
+ GURL::Replacements replacements; |
+ std::string username("user2"); |
+ std::string password("secret"); |
+ replacements.SetUsernameStr(username); |
+ replacements.SetPasswordStr(password); |
+ GURL url_with_identity = url_requiring_auth.ReplaceComponents(replacements); |
+ |
+ URLRequest r(url_with_identity, &d); |
+ r.set_context(context); |
+ r.Start(); |
+ |
+ MessageLoop::current()->Run(); |
+ |
+ EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos); |
+ |
+ // Make sure we sent the cookie in the restarted transaction. |
+ EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
+ != std::string::npos); |
+ } |
} |
TEST_F(URLRequestTest, DelayedCookieCallback) { |