| 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 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1354 | 1354 |
| 1355 // Check we see a canceled request | 1355 // Check we see a canceled request |
| 1356 EXPECT_FALSE(req.status().is_success()); | 1356 EXPECT_FALSE(req.status().is_success()); |
| 1357 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status()); | 1357 EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status()); |
| 1358 } | 1358 } |
| 1359 | 1359 |
| 1360 // Check that two different URL requests have different identifiers. | 1360 // Check that two different URL requests have different identifiers. |
| 1361 TEST_F(URLRequestTest, Identifiers) { | 1361 TEST_F(URLRequestTest, Identifiers) { |
| 1362 TestDelegate d; | 1362 TestDelegate d; |
| 1363 TestURLRequestContext context; | 1363 TestURLRequestContext context; |
| 1364 TestURLRequest req(GURL("http://example.com"), &d, &context); | 1364 TestURLRequest req(GURL("http://example.com"), &d, &context, NULL); |
| 1365 TestURLRequest other_req(GURL("http://example.com"), &d, &context); | 1365 TestURLRequest other_req(GURL("http://example.com"), &d, &context, NULL); |
| 1366 | 1366 |
| 1367 ASSERT_NE(req.identifier(), other_req.identifier()); | 1367 ASSERT_NE(req.identifier(), other_req.identifier()); |
| 1368 } | 1368 } |
| 1369 | 1369 |
| 1370 // Check that a failure to connect to the proxy is reported to the network | 1370 // Check that a failure to connect to the proxy is reported to the network |
| 1371 // delegate. | 1371 // delegate. |
| 1372 TEST_F(URLRequestTest, NetworkDelegateProxyError) { | 1372 TEST_F(URLRequestTest, NetworkDelegateProxyError) { |
| 1373 MockHostResolver host_resolver; | 1373 MockHostResolver host_resolver; |
| 1374 host_resolver.rules()->AddSimulatedFailure("*"); | 1374 host_resolver.rules()->AddSimulatedFailure("*"); |
| 1375 | 1375 |
| (...skipping 2492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3868 TestDelegate d; | 3868 TestDelegate d; |
| 3869 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); | 3869 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); |
| 3870 req.set_method("POST"); | 3870 req.set_method("POST"); |
| 3871 req.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); | 3871 req.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); |
| 3872 HttpRequestHeaders headers; | 3872 HttpRequestHeaders headers; |
| 3873 headers.SetHeader(HttpRequestHeaders::kContentLength, | 3873 headers.SetHeader(HttpRequestHeaders::kContentLength, |
| 3874 base::UintToString(arraysize(kData) - 1)); | 3874 base::UintToString(arraysize(kData) - 1)); |
| 3875 req.SetExtraRequestHeaders(headers); | 3875 req.SetExtraRequestHeaders(headers); |
| 3876 | 3876 |
| 3877 URLRequestRedirectJob* job = new URLRequestRedirectJob( | 3877 URLRequestRedirectJob* job = new URLRequestRedirectJob( |
| 3878 &req, default_context_.network_delegate(), test_server_.GetURL("echo"), | 3878 &req, &default_network_delegate_, test_server_.GetURL("echo"), |
| 3879 URLRequestRedirectJob::REDIRECT_302_FOUND); | 3879 URLRequestRedirectJob::REDIRECT_302_FOUND); |
| 3880 AddTestInterceptor()->set_main_intercept_job(job); | 3880 AddTestInterceptor()->set_main_intercept_job(job); |
| 3881 | 3881 |
| 3882 req.Start(); | 3882 req.Start(); |
| 3883 MessageLoop::current()->Run(); | 3883 MessageLoop::current()->Run(); |
| 3884 EXPECT_EQ("GET", req.method()); | 3884 EXPECT_EQ("GET", req.method()); |
| 3885 } | 3885 } |
| 3886 | 3886 |
| 3887 TEST_F(URLRequestTestHTTP, InterceptPost307RedirectPost) { | 3887 TEST_F(URLRequestTestHTTP, InterceptPost307RedirectPost) { |
| 3888 ASSERT_TRUE(test_server_.Start()); | 3888 ASSERT_TRUE(test_server_.Start()); |
| 3889 | 3889 |
| 3890 const char kData[] = "hello world"; | 3890 const char kData[] = "hello world"; |
| 3891 | 3891 |
| 3892 TestDelegate d; | 3892 TestDelegate d; |
| 3893 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); | 3893 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); |
| 3894 req.set_method("POST"); | 3894 req.set_method("POST"); |
| 3895 req.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); | 3895 req.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); |
| 3896 HttpRequestHeaders headers; | 3896 HttpRequestHeaders headers; |
| 3897 headers.SetHeader(HttpRequestHeaders::kContentLength, | 3897 headers.SetHeader(HttpRequestHeaders::kContentLength, |
| 3898 base::UintToString(arraysize(kData) - 1)); | 3898 base::UintToString(arraysize(kData) - 1)); |
| 3899 req.SetExtraRequestHeaders(headers); | 3899 req.SetExtraRequestHeaders(headers); |
| 3900 | 3900 |
| 3901 URLRequestRedirectJob* job = new URLRequestRedirectJob( | 3901 URLRequestRedirectJob* job = new URLRequestRedirectJob( |
| 3902 &req, default_context_.network_delegate(), test_server_.GetURL("echo"), | 3902 &req, &default_network_delegate_, test_server_.GetURL("echo"), |
| 3903 URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT); | 3903 URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT); |
| 3904 AddTestInterceptor()->set_main_intercept_job(job); | 3904 AddTestInterceptor()->set_main_intercept_job(job); |
| 3905 | 3905 |
| 3906 req.Start(); | 3906 req.Start(); |
| 3907 MessageLoop::current()->Run(); | 3907 MessageLoop::current()->Run(); |
| 3908 EXPECT_EQ("POST", req.method()); | 3908 EXPECT_EQ("POST", req.method()); |
| 3909 EXPECT_EQ(kData, d.data_received()); | 3909 EXPECT_EQ(kData, d.data_received()); |
| 3910 } | 3910 } |
| 3911 | 3911 |
| 3912 // Check that default A-L header is sent. | 3912 // Check that default A-L header is sent. |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4599 } | 4599 } |
| 4600 | 4600 |
| 4601 // Now create a new HttpCache with a different ssl_session_cache_shard value. | 4601 // Now create a new HttpCache with a different ssl_session_cache_shard value. |
| 4602 HttpNetworkSession::Params params; | 4602 HttpNetworkSession::Params params; |
| 4603 params.host_resolver = default_context_.host_resolver(); | 4603 params.host_resolver = default_context_.host_resolver(); |
| 4604 params.cert_verifier = default_context_.cert_verifier(); | 4604 params.cert_verifier = default_context_.cert_verifier(); |
| 4605 params.proxy_service = default_context_.proxy_service(); | 4605 params.proxy_service = default_context_.proxy_service(); |
| 4606 params.ssl_config_service = default_context_.ssl_config_service(); | 4606 params.ssl_config_service = default_context_.ssl_config_service(); |
| 4607 params.http_auth_handler_factory = | 4607 params.http_auth_handler_factory = |
| 4608 default_context_.http_auth_handler_factory(); | 4608 default_context_.http_auth_handler_factory(); |
| 4609 params.network_delegate = default_context_.network_delegate(); | 4609 params.network_delegate = &default_network_delegate_; |
| 4610 params.http_server_properties = default_context_.http_server_properties(); | 4610 params.http_server_properties = default_context_.http_server_properties(); |
| 4611 params.ssl_session_cache_shard = "alternate"; | 4611 params.ssl_session_cache_shard = "alternate"; |
| 4612 | 4612 |
| 4613 scoped_ptr<net::HttpCache> cache(new net::HttpCache( | 4613 scoped_ptr<net::HttpCache> cache(new net::HttpCache( |
| 4614 new net::HttpNetworkSession(params), | 4614 new net::HttpNetworkSession(params), |
| 4615 net::HttpCache::DefaultBackend::InMemory(0))); | 4615 net::HttpCache::DefaultBackend::InMemory(0))); |
| 4616 | 4616 |
| 4617 default_context_.set_http_transaction_factory(cache.get()); | 4617 default_context_.set_http_transaction_factory(cache.get()); |
| 4618 | 4618 |
| 4619 { | 4619 { |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5361 | 5361 |
| 5362 EXPECT_FALSE(r.is_pending()); | 5362 EXPECT_FALSE(r.is_pending()); |
| 5363 EXPECT_EQ(1, d->response_started_count()); | 5363 EXPECT_EQ(1, d->response_started_count()); |
| 5364 EXPECT_FALSE(d->received_data_before_response()); | 5364 EXPECT_FALSE(d->received_data_before_response()); |
| 5365 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 5365 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 5366 } | 5366 } |
| 5367 } | 5367 } |
| 5368 #endif // !defined(DISABLE_FTP_SUPPORT) | 5368 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 5369 | 5369 |
| 5370 } // namespace net | 5370 } // namespace net |
| OLD | NEW |