| 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 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2284 TEST_F(URLRequestTest, DoNotOverrideReferrer) { | 2284 TEST_F(URLRequestTest, DoNotOverrideReferrer) { |
| 2285 LocalHttpTestServer test_server; | 2285 LocalHttpTestServer test_server; |
| 2286 ASSERT_TRUE(test_server.Start()); | 2286 ASSERT_TRUE(test_server.Start()); |
| 2287 | 2287 |
| 2288 // If extra headers contain referer and the request contains a referer, | 2288 // If extra headers contain referer and the request contains a referer, |
| 2289 // only the latter shall be respected. | 2289 // only the latter shall be respected. |
| 2290 { | 2290 { |
| 2291 TestDelegate d; | 2291 TestDelegate d; |
| 2292 URLRequest req( | 2292 URLRequest req( |
| 2293 test_server.GetURL("echoheader?Referer"), &d, &default_context_); | 2293 test_server.GetURL("echoheader?Referer"), &d, &default_context_); |
| 2294 req.set_referrer("http://foo.com/"); | 2294 req.SetReferrer("http://foo.com/"); |
| 2295 | 2295 |
| 2296 HttpRequestHeaders headers; | 2296 HttpRequestHeaders headers; |
| 2297 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); | 2297 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); |
| 2298 req.SetExtraRequestHeaders(headers); | 2298 req.SetExtraRequestHeaders(headers); |
| 2299 | 2299 |
| 2300 req.Start(); | 2300 req.Start(); |
| 2301 MessageLoop::current()->Run(); | 2301 MessageLoop::current()->Run(); |
| 2302 | 2302 |
| 2303 EXPECT_EQ("http://foo.com/", d.data_received()); | 2303 EXPECT_EQ("http://foo.com/", d.data_received()); |
| 2304 } | 2304 } |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3316 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 3316 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
| 3317 ASSERT_TRUE(https_test_server.Start()); | 3317 ASSERT_TRUE(https_test_server.Start()); |
| 3318 | 3318 |
| 3319 // An https server is sent a request with an https referer, | 3319 // An https server is sent a request with an https referer, |
| 3320 // and responds with a redirect to an http url. The http | 3320 // and responds with a redirect to an http url. The http |
| 3321 // server should not be sent the referer. | 3321 // server should not be sent the referer. |
| 3322 GURL http_destination = test_server_.GetURL(std::string()); | 3322 GURL http_destination = test_server_.GetURL(std::string()); |
| 3323 TestDelegate d; | 3323 TestDelegate d; |
| 3324 URLRequest req(https_test_server.GetURL( | 3324 URLRequest req(https_test_server.GetURL( |
| 3325 "server-redirect?" + http_destination.spec()), &d, &default_context_); | 3325 "server-redirect?" + http_destination.spec()), &d, &default_context_); |
| 3326 req.set_referrer("https://www.referrer.com/"); | 3326 req.SetReferrer("https://www.referrer.com/"); |
| 3327 req.Start(); | 3327 req.Start(); |
| 3328 MessageLoop::current()->Run(); | 3328 MessageLoop::current()->Run(); |
| 3329 | 3329 |
| 3330 EXPECT_EQ(1, d.response_started_count()); | 3330 EXPECT_EQ(1, d.response_started_count()); |
| 3331 EXPECT_EQ(1, d.received_redirect_count()); | 3331 EXPECT_EQ(1, d.received_redirect_count()); |
| 3332 EXPECT_EQ(http_destination, req.url()); | 3332 EXPECT_EQ(http_destination, req.url()); |
| 3333 EXPECT_EQ(std::string(), req.referrer()); | 3333 EXPECT_EQ(std::string(), req.referrer()); |
| 3334 } | 3334 } |
| 3335 | 3335 |
| 3336 TEST_F(URLRequestTestHTTP, RedirectLoadTiming) { | 3336 TEST_F(URLRequestTestHTTP, RedirectLoadTiming) { |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3851 EXPECT_EQ(URLRequestStatus::FAILED, req.status().status()); | 3851 EXPECT_EQ(URLRequestStatus::FAILED, req.status().status()); |
| 3852 EXPECT_EQ(ERR_INVALID_URL, req.status().error()); | 3852 EXPECT_EQ(ERR_INVALID_URL, req.status().error()); |
| 3853 } | 3853 } |
| 3854 | 3854 |
| 3855 TEST_F(URLRequestTestHTTP, NoUserPassInReferrer) { | 3855 TEST_F(URLRequestTestHTTP, NoUserPassInReferrer) { |
| 3856 ASSERT_TRUE(test_server_.Start()); | 3856 ASSERT_TRUE(test_server_.Start()); |
| 3857 | 3857 |
| 3858 TestDelegate d; | 3858 TestDelegate d; |
| 3859 URLRequest req( | 3859 URLRequest req( |
| 3860 test_server_.GetURL("echoheader?Referer"), &d, &default_context_); | 3860 test_server_.GetURL("echoheader?Referer"), &d, &default_context_); |
| 3861 req.set_referrer("http://user:pass@foo.com/"); | 3861 req.SetReferrer("http://user:pass@foo.com/"); |
| 3862 req.Start(); | 3862 req.Start(); |
| 3863 MessageLoop::current()->Run(); | 3863 MessageLoop::current()->Run(); |
| 3864 | 3864 |
| 3865 EXPECT_EQ(std::string("http://foo.com/"), d.data_received()); | 3865 EXPECT_EQ(std::string("http://foo.com/"), d.data_received()); |
| 3866 } | 3866 } |
| 3867 | 3867 |
| 3868 TEST_F(URLRequestTestHTTP, NoFragmentInReferrer) { |
| 3869 ASSERT_TRUE(test_server_.Start()); |
| 3870 |
| 3871 TestDelegate d; |
| 3872 URLRequest req( |
| 3873 test_server_.GetURL("echoheader?Referer"), &d, &default_context_); |
| 3874 req.SetReferrer("http://foo.com/test#fragment"); |
| 3875 req.Start(); |
| 3876 MessageLoop::current()->Run(); |
| 3877 |
| 3878 EXPECT_EQ(std::string("http://foo.com/test"), d.data_received()); |
| 3879 } |
| 3880 |
| 3881 TEST_F(URLRequestTestHTTP, EmptyReferrerAfterValidReferrer) { |
| 3882 ASSERT_TRUE(test_server_.Start()); |
| 3883 |
| 3884 TestDelegate d; |
| 3885 URLRequest req( |
| 3886 test_server_.GetURL("echoheader?Referer"), &d, &default_context_); |
| 3887 req.SetReferrer("http://foo.com/test#fragment"); |
| 3888 req.SetReferrer(""); |
| 3889 req.Start(); |
| 3890 MessageLoop::current()->Run(); |
| 3891 |
| 3892 EXPECT_EQ(std::string("None"), d.data_received()); |
| 3893 } |
| 3894 |
| 3868 TEST_F(URLRequestTestHTTP, CancelRedirect) { | 3895 TEST_F(URLRequestTestHTTP, CancelRedirect) { |
| 3869 ASSERT_TRUE(test_server_.Start()); | 3896 ASSERT_TRUE(test_server_.Start()); |
| 3870 | 3897 |
| 3871 TestDelegate d; | 3898 TestDelegate d; |
| 3872 { | 3899 { |
| 3873 d.set_cancel_in_received_redirect(true); | 3900 d.set_cancel_in_received_redirect(true); |
| 3874 URLRequest req( | 3901 URLRequest req( |
| 3875 test_server_.GetURL("files/redirect-test.html"), &d, &default_context_); | 3902 test_server_.GetURL("files/redirect-test.html"), &d, &default_context_); |
| 3876 req.Start(); | 3903 req.Start(); |
| 3877 MessageLoop::current()->Run(); | 3904 MessageLoop::current()->Run(); |
| (...skipping 1834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5712 | 5739 |
| 5713 EXPECT_FALSE(r.is_pending()); | 5740 EXPECT_FALSE(r.is_pending()); |
| 5714 EXPECT_EQ(1, d->response_started_count()); | 5741 EXPECT_EQ(1, d->response_started_count()); |
| 5715 EXPECT_FALSE(d->received_data_before_response()); | 5742 EXPECT_FALSE(d->received_data_before_response()); |
| 5716 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 5743 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 5717 } | 5744 } |
| 5718 } | 5745 } |
| 5719 #endif // !defined(DISABLE_FTP_SUPPORT) | 5746 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 5720 | 5747 |
| 5721 } // namespace net | 5748 } // namespace net |
| OLD | NEW |