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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 } | 233 } |
| 234 | 234 |
| 235 UploadDataStream* CreateSimpleUploadData(const char* data) { | 235 UploadDataStream* CreateSimpleUploadData(const char* data) { |
| 236 scoped_ptr<UploadElementReader> reader( | 236 scoped_ptr<UploadElementReader> reader( |
| 237 new UploadBytesElementReader(data, strlen(data))); | 237 new UploadBytesElementReader(data, strlen(data))); |
| 238 return UploadDataStream::CreateWithReader(reader.Pass(), 0); | 238 return UploadDataStream::CreateWithReader(reader.Pass(), 0); |
| 239 } | 239 } |
| 240 | 240 |
| 241 // Verify that the SSLInfo of a successful SSL connection has valid values. | 241 // Verify that the SSLInfo of a successful SSL connection has valid values. |
| 242 void CheckSSLInfo(const SSLInfo& ssl_info) { | 242 void CheckSSLInfo(const SSLInfo& ssl_info) { |
| 243 // Allow ChromeFrame fake SSLInfo to get through. | |
| 244 if (ssl_info.cert.get() && | |
| 245 ssl_info.cert.get()->issuer().GetDisplayName() == "Chrome Internal") { | |
| 246 // -1 means unknown. | |
| 247 EXPECT_EQ(ssl_info.security_bits, -1); | |
| 248 return; | |
| 249 } | |
| 250 | |
| 251 // -1 means unknown. 0 means no encryption. | 243 // -1 means unknown. 0 means no encryption. |
| 252 EXPECT_GT(ssl_info.security_bits, 0); | 244 EXPECT_GT(ssl_info.security_bits, 0); |
| 253 | 245 |
| 254 // The cipher suite TLS_NULL_WITH_NULL_NULL (0) must not be negotiated. | 246 // The cipher suite TLS_NULL_WITH_NULL_NULL (0) must not be negotiated. |
| 255 int cipher_suite = SSLConnectionStatusToCipherSuite( | 247 int cipher_suite = SSLConnectionStatusToCipherSuite( |
| 256 ssl_info.connection_status); | 248 ssl_info.connection_status); |
| 257 EXPECT_NE(0, cipher_suite); | 249 EXPECT_NE(0, cipher_suite); |
| 258 } | 250 } |
| 259 | 251 |
| 260 void CheckFullRequestHeaders(const HttpRequestHeaders& headers, | 252 void CheckFullRequestHeaders(const HttpRequestHeaders& headers, |
| (...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1956 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority()); | 1948 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority()); |
| 1957 | 1949 |
| 1958 req.Start(); | 1950 req.Start(); |
| 1959 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority()); | 1951 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority()); |
| 1960 EXPECT_EQ(MAXIMUM_PRIORITY, job->priority()); | 1952 EXPECT_EQ(MAXIMUM_PRIORITY, job->priority()); |
| 1961 } | 1953 } |
| 1962 | 1954 |
| 1963 // TODO(droger): Support SpawnedTestServer on iOS (see http://crbug.com/148666). | 1955 // TODO(droger): Support SpawnedTestServer on iOS (see http://crbug.com/148666). |
| 1964 #if !defined(OS_IOS) | 1956 #if !defined(OS_IOS) |
| 1965 // A subclass of SpawnedTestServer that uses a statically-configured hostname. | 1957 // A subclass of SpawnedTestServer that uses a statically-configured hostname. |
| 1966 // This is to work around mysterious failures in chrome_frame_net_tests. See: | 1958 // This is to work around mysterious failures in chrome_frame_net_tests. See: |
|
wtc
2014/01/15 00:09:23
This also seems related to ChromeFrame. Should thi
grt (UTC plus 2)
2014/01/15 14:29:10
I'm not sure if the local server is still useful t
| |
| 1967 // http://crbug.com/114369 | 1959 // http://crbug.com/114369 |
| 1968 class LocalHttpTestServer : public SpawnedTestServer { | 1960 class LocalHttpTestServer : public SpawnedTestServer { |
| 1969 public: | 1961 public: |
| 1970 explicit LocalHttpTestServer(const base::FilePath& document_root) | 1962 explicit LocalHttpTestServer(const base::FilePath& document_root) |
| 1971 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, | 1963 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, |
| 1972 ScopedCustomUrlRequestTestHttpHost::value(), | 1964 ScopedCustomUrlRequestTestHttpHost::value(), |
| 1973 document_root) {} | 1965 document_root) {} |
| 1974 LocalHttpTestServer() | 1966 LocalHttpTestServer() |
| 1975 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, | 1967 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, |
| 1976 ScopedCustomUrlRequestTestHttpHost::value(), | 1968 ScopedCustomUrlRequestTestHttpHost::value(), |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2683 &default_context_); | 2675 &default_context_); |
| 2684 | 2676 |
| 2685 r.Start(); | 2677 r.Start(); |
| 2686 EXPECT_TRUE(r.is_pending()); | 2678 EXPECT_TRUE(r.is_pending()); |
| 2687 | 2679 |
| 2688 base::RunLoop().Run(); | 2680 base::RunLoop().Run(); |
| 2689 | 2681 |
| 2690 bool is_success = r.status().is_success(); | 2682 bool is_success = r.status().is_success(); |
| 2691 | 2683 |
| 2692 if (!is_success) { | 2684 if (!is_success) { |
| 2693 // Requests handled by ChromeFrame send a less precise error message, | 2685 EXPECT_TRUE(r.status().error() == ERR_RESPONSE_HEADERS_TOO_BIG); |
| 2694 // ERR_CONNECTION_ABORTED. | |
| 2695 EXPECT_TRUE(r.status().error() == ERR_RESPONSE_HEADERS_TOO_BIG || | |
| 2696 r.status().error() == ERR_CONNECTION_ABORTED); | |
| 2697 // The test server appears to be unable to handle subsequent requests | 2686 // The test server appears to be unable to handle subsequent requests |
| 2698 // after this error is triggered. Force it to restart. | 2687 // after this error is triggered. Force it to restart. |
| 2699 EXPECT_TRUE(test_server_.Stop()); | 2688 EXPECT_TRUE(test_server_.Stop()); |
| 2700 EXPECT_TRUE(test_server_.Start()); | 2689 EXPECT_TRUE(test_server_.Start()); |
| 2701 } | 2690 } |
| 2702 | 2691 |
| 2703 return is_success; | 2692 return is_success; |
| 2704 } | 2693 } |
| 2705 | 2694 |
| 2706 LocalHttpTestServer test_server_; | 2695 LocalHttpTestServer test_server_; |
| (...skipping 2098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4805 kuint64max, | 4794 kuint64max, |
| 4806 base::Time())); | 4795 base::Time())); |
| 4807 r.set_upload(make_scoped_ptr( | 4796 r.set_upload(make_scoped_ptr( |
| 4808 new UploadDataStream(element_readers.Pass(), 0))); | 4797 new UploadDataStream(element_readers.Pass(), 0))); |
| 4809 | 4798 |
| 4810 r.Start(); | 4799 r.Start(); |
| 4811 EXPECT_TRUE(r.is_pending()); | 4800 EXPECT_TRUE(r.is_pending()); |
| 4812 | 4801 |
| 4813 base::RunLoop().Run(); | 4802 base::RunLoop().Run(); |
| 4814 | 4803 |
| 4815 // TODO(tzik): Remove this #if after we stop supporting Chrome Frame. | 4804 // TODO(tzik): Remove this #if after we stop supporting Chrome Frame. |
|
wtc
2014/01/15 00:09:23
Should we also remove this?
grt (UTC plus 2)
2014/01/15 14:29:10
Done. I wonder why I didn't remove it before...
| |
| 4816 // http://crbug.com/317432 | 4805 // http://crbug.com/317432 |
| 4817 #if defined(CHROME_FRAME_NET_TESTS) | 4806 #if defined(CHROME_FRAME_NET_TESTS) |
| 4818 EXPECT_FALSE(d.request_failed()); | 4807 EXPECT_FALSE(d.request_failed()); |
| 4819 EXPECT_FALSE(d.received_data_before_response()); | 4808 EXPECT_FALSE(d.received_data_before_response()); |
| 4820 EXPECT_EQ(0, d.bytes_received()); | 4809 EXPECT_EQ(0, d.bytes_received()); |
| 4821 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); | 4810 EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status()); |
| 4822 EXPECT_EQ(OK, r.status().error()); | 4811 EXPECT_EQ(OK, r.status().error()); |
| 4823 #else | 4812 #else |
| 4824 EXPECT_TRUE(d.request_failed()); | 4813 EXPECT_TRUE(d.request_failed()); |
| 4825 EXPECT_FALSE(d.received_data_before_response()); | 4814 EXPECT_FALSE(d.received_data_before_response()); |
| (...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5955 TestDelegate d; | 5944 TestDelegate d; |
| 5956 URLRequest req(test_server_.GetURL("echoheader?User-Agent"), | 5945 URLRequest req(test_server_.GetURL("echoheader?User-Agent"), |
| 5957 DEFAULT_PRIORITY, | 5946 DEFAULT_PRIORITY, |
| 5958 &d, | 5947 &d, |
| 5959 &default_context_); | 5948 &default_context_); |
| 5960 HttpRequestHeaders headers; | 5949 HttpRequestHeaders headers; |
| 5961 headers.SetHeader(HttpRequestHeaders::kUserAgent, "Lynx (textmode)"); | 5950 headers.SetHeader(HttpRequestHeaders::kUserAgent, "Lynx (textmode)"); |
| 5962 req.SetExtraRequestHeaders(headers); | 5951 req.SetExtraRequestHeaders(headers); |
| 5963 req.Start(); | 5952 req.Start(); |
| 5964 base::RunLoop().Run(); | 5953 base::RunLoop().Run(); |
| 5965 // If the net tests are being run with ChromeFrame then we need to allow for | 5954 EXPECT_EQ(std::string("Lynx (textmode)"), d.data_received()); |
| 5966 // the 'chromeframe' suffix which is added to the user agent before the | |
| 5967 // closing parentheses. | |
| 5968 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | |
| 5969 } | 5955 } |
| 5970 | 5956 |
| 5971 // Check that a NULL HttpUserAgentSettings causes the corresponding empty | 5957 // Check that a NULL HttpUserAgentSettings causes the corresponding empty |
| 5972 // User-Agent header to be sent but does not send the Accept-Language and | 5958 // User-Agent header to be sent but does not send the Accept-Language and |
| 5973 // Accept-Charset headers. | 5959 // Accept-Charset headers. |
| 5974 TEST_F(URLRequestTestHTTP, EmptyHttpUserAgentSettings) { | 5960 TEST_F(URLRequestTestHTTP, EmptyHttpUserAgentSettings) { |
| 5975 ASSERT_TRUE(test_server_.Start()); | 5961 ASSERT_TRUE(test_server_.Start()); |
| 5976 | 5962 |
| 5977 TestNetworkDelegate network_delegate; // Must outlive URLRequests. | 5963 TestNetworkDelegate network_delegate; // Must outlive URLRequests. |
| 5978 TestURLRequestContext context(true); | 5964 TestURLRequestContext context(true); |
| (...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7616 | 7602 |
| 7617 EXPECT_FALSE(r.is_pending()); | 7603 EXPECT_FALSE(r.is_pending()); |
| 7618 EXPECT_EQ(1, d->response_started_count()); | 7604 EXPECT_EQ(1, d->response_started_count()); |
| 7619 EXPECT_FALSE(d->received_data_before_response()); | 7605 EXPECT_FALSE(d->received_data_before_response()); |
| 7620 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 7606 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 7621 } | 7607 } |
| 7622 } | 7608 } |
| 7623 #endif // !defined(DISABLE_FTP_SUPPORT) | 7609 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 7624 | 7610 |
| 7625 } // namespace net | 7611 } // namespace net |
| OLD | NEW |