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 |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <string> | |
14 | 13 |
15 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
16 #include "base/bind.h" | 15 #include "base/bind.h" |
17 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
18 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
19 #include "base/files/scoped_temp_dir.h" | 18 #include "base/files/scoped_temp_dir.h" |
20 #include "base/format_macros.h" | 19 #include "base/format_macros.h" |
21 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
22 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
23 #include "base/message_loop/message_loop.h" | 22 #include "base/message_loop/message_loop.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 #endif | 91 #endif |
93 | 92 |
94 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
95 #include "base/win/scoped_com_initializer.h" | 94 #include "base/win/scoped_com_initializer.h" |
96 #include "base/win/scoped_comptr.h" | 95 #include "base/win/scoped_comptr.h" |
97 #include "base/win/windows_version.h" | 96 #include "base/win/windows_version.h" |
98 #endif | 97 #endif |
99 | 98 |
100 using base::ASCIIToUTF16; | 99 using base::ASCIIToUTF16; |
101 using base::Time; | 100 using base::Time; |
| 101 using std::string; |
102 | 102 |
103 namespace net { | 103 namespace net { |
104 | 104 |
105 namespace { | 105 namespace { |
106 | 106 |
107 const base::string16 kChrome(ASCIIToUTF16("chrome")); | 107 const base::string16 kChrome(ASCIIToUTF16("chrome")); |
108 const base::string16 kSecret(ASCIIToUTF16("secret")); | 108 const base::string16 kSecret(ASCIIToUTF16("secret")); |
109 const base::string16 kUser(ASCIIToUTF16("user")); | 109 const base::string16 kUser(ASCIIToUTF16("user")); |
110 | 110 |
111 // Tests load timing information in the case a fresh connection was used, with | 111 // Tests load timing information in the case a fresh connection was used, with |
(...skipping 5318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5430 req->Start(); | 5430 req->Start(); |
5431 base::RunLoop().Run(); | 5431 base::RunLoop().Run(); |
5432 | 5432 |
5433 EXPECT_EQ(URLRequestStatus::SUCCESS, req->status().status()); | 5433 EXPECT_EQ(URLRequestStatus::SUCCESS, req->status().status()); |
5434 EXPECT_FALSE(req->was_cached()); | 5434 EXPECT_FALSE(req->was_cached()); |
5435 EXPECT_EQ(0, d.received_redirect_count()); | 5435 EXPECT_EQ(0, d.received_redirect_count()); |
5436 EXPECT_EQ(initial_url, req->url()); | 5436 EXPECT_EQ(initial_url, req->url()); |
5437 } | 5437 } |
5438 } | 5438 } |
5439 | 5439 |
| 5440 // Make sure an HTTP request using the "unsafe" port 443 fails. |
| 5441 // See: https://crbug.com/436451 |
| 5442 TEST_F(URLRequestTestHTTP, UnsafePort) { |
| 5443 TestDelegate d; |
| 5444 { |
| 5445 scoped_ptr<URLRequest> r(default_context_.CreateRequest( |
| 5446 GURL("http://www.google.com:443/"), DEFAULT_PRIORITY, &d, NULL)); |
| 5447 |
| 5448 r->Start(); |
| 5449 EXPECT_TRUE(r->is_pending()); |
| 5450 |
| 5451 base::RunLoop().Run(); |
| 5452 |
| 5453 EXPECT_FALSE(r->is_pending()); |
| 5454 EXPECT_EQ(URLRequestStatus::FAILED, r->status().status()); |
| 5455 EXPECT_EQ(ERR_UNSAFE_PORT, r->status().error()); |
| 5456 } |
| 5457 } |
| 5458 |
5440 // Tests that redirection to an unsafe URL is allowed when it has been marked as | 5459 // Tests that redirection to an unsafe URL is allowed when it has been marked as |
5441 // safe. | 5460 // safe. |
5442 TEST_F(URLRequestTestHTTP, UnsafeRedirectToWhitelistedUnsafeURL) { | 5461 TEST_F(URLRequestTestHTTP, UnsafeRedirectToWhitelistedUnsafeURL) { |
5443 ASSERT_TRUE(test_server_.Start()); | 5462 ASSERT_TRUE(test_server_.Start()); |
5444 | 5463 |
5445 GURL unsafe_url("data:text/html,this-is-considered-an-unsafe-url"); | 5464 GURL unsafe_url("data:text/html,this-is-considered-an-unsafe-url"); |
5446 default_network_delegate_.set_redirect_on_headers_received_url(unsafe_url); | 5465 default_network_delegate_.set_redirect_on_headers_received_url(unsafe_url); |
5447 default_network_delegate_.set_allowed_unsafe_redirect_url(unsafe_url); | 5466 default_network_delegate_.set_allowed_unsafe_redirect_url(unsafe_url); |
5448 | 5467 |
5449 TestDelegate d; | 5468 TestDelegate d; |
(...skipping 3367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8817 | 8836 |
8818 EXPECT_FALSE(r->is_pending()); | 8837 EXPECT_FALSE(r->is_pending()); |
8819 EXPECT_EQ(1, d->response_started_count()); | 8838 EXPECT_EQ(1, d->response_started_count()); |
8820 EXPECT_FALSE(d->received_data_before_response()); | 8839 EXPECT_FALSE(d->received_data_before_response()); |
8821 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 8840 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
8822 } | 8841 } |
8823 } | 8842 } |
8824 #endif // !defined(DISABLE_FTP_SUPPORT) | 8843 #endif // !defined(DISABLE_FTP_SUPPORT) |
8825 | 8844 |
8826 } // namespace net | 8845 } // namespace net |
OLD | NEW |