OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #endif | 10 #endif |
(...skipping 2917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2928 r.Start(); | 2928 r.Start(); |
2929 | 2929 |
2930 MessageLoop::current()->Run(); | 2930 MessageLoop::current()->Run(); |
2931 | 2931 |
2932 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); | 2932 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); |
2933 | 2933 |
2934 // Make sure we sent the cookie in the restarted transaction. | 2934 // Make sure we sent the cookie in the restarted transaction. |
2935 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") | 2935 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
2936 != std::string::npos); | 2936 != std::string::npos); |
2937 } | 2937 } |
| 2938 |
| 2939 // Same test as above, except this time the restart is initiated earlier |
| 2940 // (without user intervention since identity is embedded in the URL). |
| 2941 { |
| 2942 TestNetworkDelegate network_delegate; // must outlive URLRequest |
| 2943 TestURLRequestContext context(true); |
| 2944 context.set_network_delegate(&network_delegate); |
| 2945 context.Init(); |
| 2946 |
| 2947 TestDelegate d; |
| 2948 |
| 2949 GURL::Replacements replacements; |
| 2950 std::string username("user2"); |
| 2951 std::string password("secret"); |
| 2952 replacements.SetUsernameStr(username); |
| 2953 replacements.SetPasswordStr(password); |
| 2954 GURL url_with_identity = url_requiring_auth.ReplaceComponents(replacements); |
| 2955 |
| 2956 URLRequest r(url_with_identity, &d); |
| 2957 r.set_context(&context); |
| 2958 r.Start(); |
| 2959 |
| 2960 MessageLoop::current()->Run(); |
| 2961 |
| 2962 EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos); |
| 2963 |
| 2964 // Make sure we sent the cookie in the restarted transaction. |
| 2965 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
| 2966 != std::string::npos); |
| 2967 } |
2938 } | 2968 } |
2939 | 2969 |
2940 TEST_F(URLRequestTest, DelayedCookieCallback) { | 2970 TEST_F(URLRequestTest, DelayedCookieCallback) { |
2941 LocalHttpTestServer test_server; | 2971 LocalHttpTestServer test_server; |
2942 ASSERT_TRUE(test_server.Start()); | 2972 ASSERT_TRUE(test_server.Start()); |
2943 | 2973 |
2944 TestURLRequestContext context; | 2974 TestURLRequestContext context; |
2945 scoped_refptr<DelayedCookieMonster> delayed_cm = | 2975 scoped_refptr<DelayedCookieMonster> delayed_cm = |
2946 new DelayedCookieMonster(); | 2976 new DelayedCookieMonster(); |
2947 scoped_refptr<CookieStore> cookie_store = delayed_cm; | 2977 scoped_refptr<CookieStore> cookie_store = delayed_cm; |
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4577 req.SetExtraRequestHeaders(headers); | 4607 req.SetExtraRequestHeaders(headers); |
4578 req.Start(); | 4608 req.Start(); |
4579 MessageLoop::current()->Run(); | 4609 MessageLoop::current()->Run(); |
4580 // If the net tests are being run with ChromeFrame then we need to allow for | 4610 // If the net tests are being run with ChromeFrame then we need to allow for |
4581 // the 'chromeframe' suffix which is added to the user agent before the | 4611 // the 'chromeframe' suffix which is added to the user agent before the |
4582 // closing parentheses. | 4612 // closing parentheses. |
4583 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4613 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
4584 } | 4614 } |
4585 | 4615 |
4586 } // namespace net | 4616 } // namespace net |
OLD | NEW |