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 3042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3053 EXPECT_TRUE(headers->GetNormalizedHeader("content-type", &header)); | 3053 EXPECT_TRUE(headers->GetNormalizedHeader("content-type", &header)); |
3054 EXPECT_EQ("text/html; charset=ISO-8859-1", header); | 3054 EXPECT_EQ("text/html; charset=ISO-8859-1", header); |
3055 | 3055 |
3056 // The response has two "X-Multiple-Entries" headers. | 3056 // The response has two "X-Multiple-Entries" headers. |
3057 // This verfies our output has them concatenated together. | 3057 // This verfies our output has them concatenated together. |
3058 header.clear(); | 3058 header.clear(); |
3059 EXPECT_TRUE(headers->GetNormalizedHeader("x-multiple-entries", &header)); | 3059 EXPECT_TRUE(headers->GetNormalizedHeader("x-multiple-entries", &header)); |
3060 EXPECT_EQ("a, b", header); | 3060 EXPECT_EQ("a, b", header); |
3061 } | 3061 } |
3062 | 3062 |
| 3063 TEST_F(URLRequestTestHTTP, ProcessSTS) { |
| 3064 TestServer::SSLOptions ssl_options; |
| 3065 TestServer https_test_server( |
| 3066 TestServer::TYPE_HTTPS, |
| 3067 ssl_options, |
| 3068 FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); |
| 3069 ASSERT_TRUE(https_test_server.Start()); |
| 3070 |
| 3071 TestDelegate d; |
| 3072 URLRequest request( |
| 3073 https_test_server.GetURL("files/hsts-headers.html"), |
| 3074 &d, |
| 3075 &default_context_); |
| 3076 request.Start(); |
| 3077 MessageLoop::current()->Run(); |
| 3078 |
| 3079 TransportSecurityState* security_state = |
| 3080 default_context_.transport_security_state(); |
| 3081 bool sni_available = true; |
| 3082 TransportSecurityState::DomainState domain_state; |
| 3083 EXPECT_TRUE(security_state->GetDomainState( |
| 3084 TestServer::kLocalhost, sni_available, &domain_state)); |
| 3085 EXPECT_EQ(TransportSecurityState::DomainState::MODE_FORCE_HTTPS, |
| 3086 domain_state.upgrade_mode); |
| 3087 EXPECT_TRUE(domain_state.include_subdomains); |
| 3088 } |
| 3089 |
| 3090 TEST_F(URLRequestTestHTTP, ProcessSTSOnce) { |
| 3091 TestServer::SSLOptions ssl_options; |
| 3092 TestServer https_test_server( |
| 3093 TestServer::TYPE_HTTPS, |
| 3094 ssl_options, |
| 3095 FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); |
| 3096 ASSERT_TRUE(https_test_server.Start()); |
| 3097 |
| 3098 TestDelegate d; |
| 3099 URLRequest request( |
| 3100 https_test_server.GetURL("files/hsts-multiple-headers.html"), |
| 3101 &d, |
| 3102 &default_context_); |
| 3103 request.Start(); |
| 3104 MessageLoop::current()->Run(); |
| 3105 |
| 3106 // We should have set parameters from the first header, not the second. |
| 3107 TransportSecurityState* security_state = |
| 3108 default_context_.transport_security_state(); |
| 3109 bool sni_available = true; |
| 3110 TransportSecurityState::DomainState domain_state; |
| 3111 EXPECT_TRUE(security_state->GetDomainState( |
| 3112 TestServer::kLocalhost, sni_available, &domain_state)); |
| 3113 EXPECT_EQ(TransportSecurityState::DomainState::MODE_FORCE_HTTPS, |
| 3114 domain_state.upgrade_mode); |
| 3115 EXPECT_FALSE(domain_state.include_subdomains); |
| 3116 } |
| 3117 |
3063 TEST_F(URLRequestTestHTTP, ContentTypeNormalizationTest) { | 3118 TEST_F(URLRequestTestHTTP, ContentTypeNormalizationTest) { |
3064 ASSERT_TRUE(test_server_.Start()); | 3119 ASSERT_TRUE(test_server_.Start()); |
3065 | 3120 |
3066 TestDelegate d; | 3121 TestDelegate d; |
3067 URLRequest req(test_server_.GetURL( | 3122 URLRequest req(test_server_.GetURL( |
3068 "files/content-type-normalization.html"), &d, &default_context_); | 3123 "files/content-type-normalization.html"), &d, &default_context_); |
3069 req.Start(); | 3124 req.Start(); |
3070 MessageLoop::current()->Run(); | 3125 MessageLoop::current()->Run(); |
3071 | 3126 |
3072 std::string mime_type; | 3127 std::string mime_type; |
(...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4833 | 4888 |
4834 EXPECT_FALSE(r.is_pending()); | 4889 EXPECT_FALSE(r.is_pending()); |
4835 EXPECT_EQ(1, d->response_started_count()); | 4890 EXPECT_EQ(1, d->response_started_count()); |
4836 EXPECT_FALSE(d->received_data_before_response()); | 4891 EXPECT_FALSE(d->received_data_before_response()); |
4837 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 4892 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
4838 } | 4893 } |
4839 } | 4894 } |
4840 #endif // !defined(DISABLE_FTP_SUPPORT) | 4895 #endif // !defined(DISABLE_FTP_SUPPORT) |
4841 | 4896 |
4842 } // namespace net | 4897 } // namespace net |
OLD | NEW |