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 2498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3874 TestDelegate d; | 3874 TestDelegate d; |
3875 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); | 3875 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); |
3876 req.set_method("POST"); | 3876 req.set_method("POST"); |
3877 req.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); | 3877 req.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); |
3878 HttpRequestHeaders headers; | 3878 HttpRequestHeaders headers; |
3879 headers.SetHeader(HttpRequestHeaders::kContentLength, | 3879 headers.SetHeader(HttpRequestHeaders::kContentLength, |
3880 base::UintToString(arraysize(kData) - 1)); | 3880 base::UintToString(arraysize(kData) - 1)); |
3881 req.SetExtraRequestHeaders(headers); | 3881 req.SetExtraRequestHeaders(headers); |
3882 | 3882 |
3883 URLRequestRedirectJob* job = new URLRequestRedirectJob( | 3883 URLRequestRedirectJob* job = new URLRequestRedirectJob( |
3884 &req, default_context_.network_delegate(), test_server_.GetURL("echo"), | 3884 &req, &default_network_delegate_, test_server_.GetURL("echo"), |
3885 URLRequestRedirectJob::REDIRECT_302_FOUND); | 3885 URLRequestRedirectJob::REDIRECT_302_FOUND); |
3886 AddTestInterceptor()->set_main_intercept_job(job); | 3886 AddTestInterceptor()->set_main_intercept_job(job); |
3887 | 3887 |
3888 req.Start(); | 3888 req.Start(); |
3889 MessageLoop::current()->Run(); | 3889 MessageLoop::current()->Run(); |
3890 EXPECT_EQ("GET", req.method()); | 3890 EXPECT_EQ("GET", req.method()); |
3891 } | 3891 } |
3892 | 3892 |
3893 TEST_F(URLRequestTestHTTP, InterceptPost307RedirectPost) { | 3893 TEST_F(URLRequestTestHTTP, InterceptPost307RedirectPost) { |
3894 ASSERT_TRUE(test_server_.Start()); | 3894 ASSERT_TRUE(test_server_.Start()); |
3895 | 3895 |
3896 const char kData[] = "hello world"; | 3896 const char kData[] = "hello world"; |
3897 | 3897 |
3898 TestDelegate d; | 3898 TestDelegate d; |
3899 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); | 3899 URLRequest req(test_server_.GetURL("empty.html"), &d, &default_context_); |
3900 req.set_method("POST"); | 3900 req.set_method("POST"); |
3901 req.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); | 3901 req.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData))); |
3902 HttpRequestHeaders headers; | 3902 HttpRequestHeaders headers; |
3903 headers.SetHeader(HttpRequestHeaders::kContentLength, | 3903 headers.SetHeader(HttpRequestHeaders::kContentLength, |
3904 base::UintToString(arraysize(kData) - 1)); | 3904 base::UintToString(arraysize(kData) - 1)); |
3905 req.SetExtraRequestHeaders(headers); | 3905 req.SetExtraRequestHeaders(headers); |
3906 | 3906 |
3907 URLRequestRedirectJob* job = new URLRequestRedirectJob( | 3907 URLRequestRedirectJob* job = new URLRequestRedirectJob( |
3908 &req, default_context_.network_delegate(), test_server_.GetURL("echo"), | 3908 &req, &default_network_delegate_, test_server_.GetURL("echo"), |
3909 URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT); | 3909 URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT); |
3910 AddTestInterceptor()->set_main_intercept_job(job); | 3910 AddTestInterceptor()->set_main_intercept_job(job); |
3911 | 3911 |
3912 req.Start(); | 3912 req.Start(); |
3913 MessageLoop::current()->Run(); | 3913 MessageLoop::current()->Run(); |
3914 EXPECT_EQ("POST", req.method()); | 3914 EXPECT_EQ("POST", req.method()); |
3915 EXPECT_EQ(kData, d.data_received()); | 3915 EXPECT_EQ(kData, d.data_received()); |
3916 } | 3916 } |
3917 | 3917 |
3918 // Check that default A-L header is sent. | 3918 // Check that default A-L header is sent. |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4605 } | 4605 } |
4606 | 4606 |
4607 // Now create a new HttpCache with a different ssl_session_cache_shard value. | 4607 // Now create a new HttpCache with a different ssl_session_cache_shard value. |
4608 HttpNetworkSession::Params params; | 4608 HttpNetworkSession::Params params; |
4609 params.host_resolver = default_context_.host_resolver(); | 4609 params.host_resolver = default_context_.host_resolver(); |
4610 params.cert_verifier = default_context_.cert_verifier(); | 4610 params.cert_verifier = default_context_.cert_verifier(); |
4611 params.proxy_service = default_context_.proxy_service(); | 4611 params.proxy_service = default_context_.proxy_service(); |
4612 params.ssl_config_service = default_context_.ssl_config_service(); | 4612 params.ssl_config_service = default_context_.ssl_config_service(); |
4613 params.http_auth_handler_factory = | 4613 params.http_auth_handler_factory = |
4614 default_context_.http_auth_handler_factory(); | 4614 default_context_.http_auth_handler_factory(); |
4615 params.network_delegate = default_context_.network_delegate(); | 4615 params.network_delegate = &default_network_delegate_; |
4616 params.http_server_properties = default_context_.http_server_properties(); | 4616 params.http_server_properties = default_context_.http_server_properties(); |
4617 params.ssl_session_cache_shard = "alternate"; | 4617 params.ssl_session_cache_shard = "alternate"; |
4618 | 4618 |
4619 scoped_ptr<net::HttpCache> cache(new net::HttpCache( | 4619 scoped_ptr<net::HttpCache> cache(new net::HttpCache( |
4620 new net::HttpNetworkSession(params), | 4620 new net::HttpNetworkSession(params), |
4621 net::HttpCache::DefaultBackend::InMemory(0))); | 4621 net::HttpCache::DefaultBackend::InMemory(0))); |
4622 | 4622 |
4623 default_context_.set_http_transaction_factory(cache.get()); | 4623 default_context_.set_http_transaction_factory(cache.get()); |
4624 | 4624 |
4625 { | 4625 { |
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5367 | 5367 |
5368 EXPECT_FALSE(r.is_pending()); | 5368 EXPECT_FALSE(r.is_pending()); |
5369 EXPECT_EQ(1, d->response_started_count()); | 5369 EXPECT_EQ(1, d->response_started_count()); |
5370 EXPECT_FALSE(d->received_data_before_response()); | 5370 EXPECT_FALSE(d->received_data_before_response()); |
5371 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 5371 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
5372 } | 5372 } |
5373 } | 5373 } |
5374 #endif // !defined(DISABLE_FTP_SUPPORT) | 5374 #endif // !defined(DISABLE_FTP_SUPPORT) |
5375 | 5375 |
5376 } // namespace net | 5376 } // namespace net |
OLD | NEW |