| 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 "net/url_request/url_fetcher_impl.h" | 5 #include "net/url_request/url_fetcher_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "net/base/upload_file_element_reader.h" | 26 #include "net/base/upload_file_element_reader.h" |
| 27 #include "net/dns/mock_host_resolver.h" | 27 #include "net/dns/mock_host_resolver.h" |
| 28 #include "net/http/http_response_headers.h" | 28 #include "net/http/http_response_headers.h" |
| 29 #include "net/test/spawned_test_server/spawned_test_server.h" | 29 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 30 #include "net/url_request/url_fetcher_delegate.h" | 30 #include "net/url_request/url_fetcher_delegate.h" |
| 31 #include "net/url_request/url_request_context_getter.h" | 31 #include "net/url_request/url_request_context_getter.h" |
| 32 #include "net/url_request/url_request_test_util.h" | 32 #include "net/url_request/url_request_test_util.h" |
| 33 #include "net/url_request/url_request_throttler_manager.h" | 33 #include "net/url_request/url_request_throttler_manager.h" |
| 34 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 35 | 35 |
| 36 #if defined(USE_NSS) || defined(OS_IOS) | 36 #if defined(USE_NSS_CERTS) || defined(OS_IOS) |
| 37 #include "net/cert_net/nss_ocsp.h" | 37 #include "net/cert_net/nss_ocsp.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 namespace net { | 40 namespace net { |
| 41 | 41 |
| 42 using base::Time; | 42 using base::Time; |
| 43 using base::TimeDelta; | 43 using base::TimeDelta; |
| 44 | 44 |
| 45 // TODO(eroman): Add a regression test for http://crbug.com/40505. | 45 // TODO(eroman): Add a regression test for http://crbug.com/40505. |
| 46 | 46 |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 hanging_url_ = | 313 hanging_url_ = |
| 314 GURL(base::StringPrintf("http://example.com:%d/defaultresponse", | 314 GURL(base::StringPrintf("http://example.com:%d/defaultresponse", |
| 315 test_server_->host_port_pair().port())); | 315 test_server_->host_port_pair().port())); |
| 316 ASSERT_TRUE(hanging_url_.is_valid()); | 316 ASSERT_TRUE(hanging_url_.is_valid()); |
| 317 | 317 |
| 318 context_.reset(new TestURLRequestContext(true)); | 318 context_.reset(new TestURLRequestContext(true)); |
| 319 context_->set_host_resolver(&resolver_); | 319 context_->set_host_resolver(&resolver_); |
| 320 context_->set_throttler_manager(&throttler_manager_); | 320 context_->set_throttler_manager(&throttler_manager_); |
| 321 context_->Init(); | 321 context_->Init(); |
| 322 | 322 |
| 323 #if defined(USE_NSS) || defined(OS_IOS) | 323 #if defined(USE_NSS_CERTS) || defined(OS_IOS) |
| 324 crypto::EnsureNSSInit(); | 324 crypto::EnsureNSSInit(); |
| 325 EnsureNSSHttpIOInit(); | 325 EnsureNSSHttpIOInit(); |
| 326 #endif | 326 #endif |
| 327 } | 327 } |
| 328 | 328 |
| 329 void TearDown() override { | 329 void TearDown() override { |
| 330 #if defined(USE_NSS) || defined(OS_IOS) | 330 #if defined(USE_NSS_CERTS) || defined(OS_IOS) |
| 331 ShutdownNSSHttpIO(); | 331 ShutdownNSSHttpIO(); |
| 332 #endif | 332 #endif |
| 333 } | 333 } |
| 334 | 334 |
| 335 // Initializes |test_server_| without starting it. Allows subclasses to use | 335 // Initializes |test_server_| without starting it. Allows subclasses to use |
| 336 // their own server configuration. | 336 // their own server configuration. |
| 337 virtual void SetUpServer() { | 337 virtual void SetUpServer() { |
| 338 test_server_.reset(new SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, | 338 test_server_.reset(new SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, |
| 339 SpawnedTestServer::kLocalhost, | 339 SpawnedTestServer::kLocalhost, |
| 340 base::FilePath(kDocRoot))); | 340 base::FilePath(kDocRoot))); |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1344 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); | 1344 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); |
| 1345 EXPECT_TRUE(delegate.fetcher()->GetCookies().empty()); | 1345 EXPECT_TRUE(delegate.fetcher()->GetCookies().empty()); |
| 1346 std::string data; | 1346 std::string data; |
| 1347 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); | 1347 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); |
| 1348 EXPECT_TRUE(data.empty()); | 1348 EXPECT_TRUE(data.empty()); |
| 1349 } | 1349 } |
| 1350 | 1350 |
| 1351 } // namespace | 1351 } // namespace |
| 1352 | 1352 |
| 1353 } // namespace net | 1353 } // namespace net |
| OLD | NEW |