| 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 2919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2930 r.Start(); | 2930 r.Start(); |
| 2931 | 2931 |
| 2932 MessageLoop::current()->Run(); | 2932 MessageLoop::current()->Run(); |
| 2933 | 2933 |
| 2934 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); | 2934 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); |
| 2935 | 2935 |
| 2936 // Make sure we sent the cookie in the restarted transaction. | 2936 // Make sure we sent the cookie in the restarted transaction. |
| 2937 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") | 2937 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") |
| 2938 != std::string::npos); | 2938 != std::string::npos); |
| 2939 } | 2939 } |
| 2940 | |
| 2941 // Same test as above, except this time the restart is initiated earlier | |
| 2942 // (without user intervention since identity is embedded in the URL). | |
| 2943 { | |
| 2944 TestNetworkDelegate network_delegate; // must outlive URLRequest | |
| 2945 TestURLRequestContext context(true); | |
| 2946 context.set_network_delegate(&network_delegate); | |
| 2947 context.Init(); | |
| 2948 | |
| 2949 TestDelegate d; | |
| 2950 | |
| 2951 GURL::Replacements replacements; | |
| 2952 std::string username("user2"); | |
| 2953 std::string password("secret"); | |
| 2954 replacements.SetUsernameStr(username); | |
| 2955 replacements.SetPasswordStr(password); | |
| 2956 GURL url_with_identity = url_requiring_auth.ReplaceComponents(replacements); | |
| 2957 | |
| 2958 URLRequest r(url_with_identity, &d); | |
| 2959 r.set_context(&context); | |
| 2960 r.Start(); | |
| 2961 | |
| 2962 MessageLoop::current()->Run(); | |
| 2963 | |
| 2964 EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos); | |
| 2965 | |
| 2966 // Make sure we sent the cookie in the restarted transaction. | |
| 2967 EXPECT_TRUE(d.data_received().find("Cookie: got_challenged=true") | |
| 2968 != std::string::npos); | |
| 2969 } | |
| 2970 } | 2940 } |
| 2971 | 2941 |
| 2972 TEST_F(URLRequestTest, DelayedCookieCallback) { | 2942 TEST_F(URLRequestTest, DelayedCookieCallback) { |
| 2973 LocalHttpTestServer test_server; | 2943 LocalHttpTestServer test_server; |
| 2974 ASSERT_TRUE(test_server.Start()); | 2944 ASSERT_TRUE(test_server.Start()); |
| 2975 | 2945 |
| 2976 scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); | 2946 scoped_refptr<URLRequestContext> context(new TestURLRequestContext()); |
| 2977 scoped_refptr<DelayedCookieMonster> delayed_cm = | 2947 scoped_refptr<DelayedCookieMonster> delayed_cm = |
| 2978 new DelayedCookieMonster(); | 2948 new DelayedCookieMonster(); |
| 2979 scoped_refptr<CookieStore> cookie_store = delayed_cm; | 2949 scoped_refptr<CookieStore> cookie_store = delayed_cm; |
| (...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4610 req.SetExtraRequestHeaders(headers); | 4580 req.SetExtraRequestHeaders(headers); |
| 4611 req.Start(); | 4581 req.Start(); |
| 4612 MessageLoop::current()->Run(); | 4582 MessageLoop::current()->Run(); |
| 4613 // If the net tests are being run with ChromeFrame then we need to allow for | 4583 // If the net tests are being run with ChromeFrame then we need to allow for |
| 4614 // the 'chromeframe' suffix which is added to the user agent before the | 4584 // the 'chromeframe' suffix which is added to the user agent before the |
| 4615 // closing parentheses. | 4585 // closing parentheses. |
| 4616 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4586 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
| 4617 } | 4587 } |
| 4618 | 4588 |
| 4619 } // namespace net | 4589 } // namespace net |
| OLD | NEW |