Chromium Code Reviews| 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 6000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6011 TEST_F(URLRequestTestHTTP, Redirect307Tests) { | 6011 TEST_F(URLRequestTestHTTP, Redirect307Tests) { |
| 6012 ASSERT_TRUE(test_server_.Start()); | 6012 ASSERT_TRUE(test_server_.Start()); |
| 6013 | 6013 |
| 6014 const GURL url = test_server_.GetURL("files/redirect307-to-echo"); | 6014 const GURL url = test_server_.GetURL("files/redirect307-to-echo"); |
| 6015 | 6015 |
| 6016 HTTPRedirectMethodTest(url, "POST", "POST", true); | 6016 HTTPRedirectMethodTest(url, "POST", "POST", true); |
| 6017 HTTPRedirectMethodTest(url, "PUT", "PUT", true); | 6017 HTTPRedirectMethodTest(url, "PUT", "PUT", true); |
| 6018 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false); | 6018 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false); |
| 6019 } | 6019 } |
| 6020 | 6020 |
| 6021 TEST_F(URLRequestTestHTTP, Redirect308Tests) { | |
| 6022 ASSERT_TRUE(test_server_.Start()); | |
| 6023 | |
| 6024 const GURL url = test_server_.GetURL("files/redirect308-to-echo"); | |
| 6025 | |
| 6026 HTTPRedirectMethodTest(url, "POST", "POST", true); | |
| 6027 HTTPRedirectMethodTest(url, "PUT", "PUT", true); | |
| 6028 HTTPRedirectMethodTest(url, "HEAD", "HEAD", false); | |
| 6029 } | |
| 6030 | |
| 6031 // Make sure that 308 responses without bodies are not treated as redirects. | |
| 6032 // Certain legacy apis that pre-date the response code expect this behavior | |
| 6033 // (Like Google Drive). | |
| 6034 TEST_F(URLRequestTestHTTP, NoRedirectOn308WithoutLocationHeader) { | |
| 6035 ASSERT_TRUE(test_server_.Start()); | |
| 6036 | |
| 6037 TestDelegate d; | |
| 6038 const GURL url = test_server_.GetURL("files/308-without-location-header"); | |
| 6039 | |
| 6040 URLRequest request(url, DEFAULT_PRIORITY, &d, &default_context_); | |
| 6041 | |
| 6042 request.Start(); | |
| 6043 base::RunLoop().Run(); | |
| 6044 EXPECT_EQ(URLRequestStatus::SUCCESS, request.status().status()); | |
| 6045 EXPECT_EQ(OK, request.status().error()); | |
| 6046 EXPECT_EQ(0, d.received_redirect_count()); | |
| 6047 EXPECT_EQ("This is not a redirect.", d.data_received()); | |
| 6048 } | |
|
willchan no longer on Chromium
2014/04/23 22:24:03
Can you also verify the response code just to show
mmenke
2014/04/24 00:13:47
Good idea, done.
| |
| 6049 | |
| 6021 TEST_F(URLRequestTestHTTP, Redirect302PreserveReferenceFragment) { | 6050 TEST_F(URLRequestTestHTTP, Redirect302PreserveReferenceFragment) { |
| 6022 ASSERT_TRUE(test_server_.Start()); | 6051 ASSERT_TRUE(test_server_.Start()); |
| 6023 | 6052 |
| 6024 GURL original_url(test_server_.GetURL("files/redirect302-to-echo#fragment")); | 6053 GURL original_url(test_server_.GetURL("files/redirect302-to-echo#fragment")); |
| 6025 GURL expected_url(test_server_.GetURL("echo#fragment")); | 6054 GURL expected_url(test_server_.GetURL("echo#fragment")); |
| 6026 | 6055 |
| 6027 TestDelegate d; | 6056 TestDelegate d; |
| 6028 { | 6057 { |
| 6029 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &default_context_); | 6058 URLRequest r(original_url, DEFAULT_PRIORITY, &d, &default_context_); |
| 6030 | 6059 |
| (...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7964 | 7993 |
| 7965 EXPECT_FALSE(r.is_pending()); | 7994 EXPECT_FALSE(r.is_pending()); |
| 7966 EXPECT_EQ(1, d->response_started_count()); | 7995 EXPECT_EQ(1, d->response_started_count()); |
| 7967 EXPECT_FALSE(d->received_data_before_response()); | 7996 EXPECT_FALSE(d->received_data_before_response()); |
| 7968 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 7997 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 7969 } | 7998 } |
| 7970 } | 7999 } |
| 7971 #endif // !defined(DISABLE_FTP_SUPPORT) | 8000 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 7972 | 8001 |
| 7973 } // namespace net | 8002 } // namespace net |
| OLD | NEW |