OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <limits> | 10 #include <limits> |
(...skipping 11495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11506 { TestRound(kConnect, kProxyChallenge, OK), | 11506 { TestRound(kConnect, kProxyChallenge, OK), |
11507 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 11507 TestRound(kConnectProxyAuth, kProxyConnected, OK, |
11508 &kGet, &kServerChallenge), | 11508 &kGet, &kServerChallenge), |
11509 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 11509 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
11510 }; | 11510 }; |
11511 | 11511 |
11512 for (size_t i = 0; i < arraysize(test_configs); ++i) { | 11512 for (size_t i = 0; i < arraysize(test_configs); ++i) { |
11513 HttpAuthHandlerMock::Factory* auth_factory( | 11513 HttpAuthHandlerMock::Factory* auth_factory( |
11514 new HttpAuthHandlerMock::Factory()); | 11514 new HttpAuthHandlerMock::Factory()); |
11515 session_deps_.http_auth_handler_factory.reset(auth_factory); | 11515 session_deps_.http_auth_handler_factory.reset(auth_factory); |
| 11516 SSLInfo empty_ssl_info; |
11516 const TestConfig& test_config = test_configs[i]; | 11517 const TestConfig& test_config = test_configs[i]; |
11517 | 11518 |
11518 // Set up authentication handlers as necessary. | 11519 // Set up authentication handlers as necessary. |
11519 if (test_config.proxy_auth_timing != AUTH_NONE) { | 11520 if (test_config.proxy_auth_timing != AUTH_NONE) { |
11520 for (int n = 0; n < 2; n++) { | 11521 for (int n = 0; n < 2; n++) { |
11521 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); | 11522 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); |
11522 std::string auth_challenge = "Mock realm=proxy"; | 11523 std::string auth_challenge = "Mock realm=proxy"; |
11523 GURL origin(test_config.proxy_url); | 11524 GURL origin(test_config.proxy_url); |
11524 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), | 11525 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), |
11525 auth_challenge.end()); | 11526 auth_challenge.end()); |
11526 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_PROXY, | 11527 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_PROXY, |
11527 origin, BoundNetLog()); | 11528 empty_ssl_info, origin, BoundNetLog()); |
11528 auth_handler->SetGenerateExpectation( | 11529 auth_handler->SetGenerateExpectation( |
11529 test_config.proxy_auth_timing == AUTH_ASYNC, | 11530 test_config.proxy_auth_timing == AUTH_ASYNC, |
11530 test_config.proxy_auth_rv); | 11531 test_config.proxy_auth_rv); |
11531 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); | 11532 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); |
11532 } | 11533 } |
11533 } | 11534 } |
11534 if (test_config.server_auth_timing != AUTH_NONE) { | 11535 if (test_config.server_auth_timing != AUTH_NONE) { |
11535 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); | 11536 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); |
11536 std::string auth_challenge = "Mock realm=server"; | 11537 std::string auth_challenge = "Mock realm=server"; |
11537 GURL origin(test_config.server_url); | 11538 GURL origin(test_config.server_url); |
11538 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), | 11539 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), |
11539 auth_challenge.end()); | 11540 auth_challenge.end()); |
11540 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER, | 11541 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER, |
11541 origin, BoundNetLog()); | 11542 empty_ssl_info, origin, BoundNetLog()); |
11542 auth_handler->SetGenerateExpectation( | 11543 auth_handler->SetGenerateExpectation( |
11543 test_config.server_auth_timing == AUTH_ASYNC, | 11544 test_config.server_auth_timing == AUTH_ASYNC, |
11544 test_config.server_auth_rv); | 11545 test_config.server_auth_rv); |
11545 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER); | 11546 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER); |
11546 } | 11547 } |
11547 if (test_config.proxy_url) { | 11548 if (test_config.proxy_url) { |
11548 session_deps_.proxy_service = | 11549 session_deps_.proxy_service = |
11549 ProxyService::CreateFixed(test_config.proxy_url); | 11550 ProxyService::CreateFixed(test_config.proxy_url); |
11550 } else { | 11551 } else { |
11551 session_deps_.proxy_service = ProxyService::CreateDirect(); | 11552 session_deps_.proxy_service = ProxyService::CreateDirect(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11640 session_deps_.proxy_service = ProxyService::CreateDirect(); | 11641 session_deps_.proxy_service = ProxyService::CreateDirect(); |
11641 session_deps_.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); | 11642 session_deps_.host_resolver->rules()->AddRule("www.example.com", "10.0.0.1"); |
11642 session_deps_.host_resolver->set_synchronous_mode(true); | 11643 session_deps_.host_resolver->set_synchronous_mode(true); |
11643 | 11644 |
11644 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); | 11645 HttpAuthHandlerMock* auth_handler(new HttpAuthHandlerMock()); |
11645 auth_handler->set_connection_based(true); | 11646 auth_handler->set_connection_based(true); |
11646 std::string auth_challenge = "Mock realm=server"; | 11647 std::string auth_challenge = "Mock realm=server"; |
11647 GURL origin("http://www.example.com"); | 11648 GURL origin("http://www.example.com"); |
11648 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), | 11649 HttpAuthChallengeTokenizer tokenizer(auth_challenge.begin(), |
11649 auth_challenge.end()); | 11650 auth_challenge.end()); |
| 11651 SSLInfo empty_ssl_info; |
11650 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER, | 11652 auth_handler->InitFromChallenge(&tokenizer, HttpAuth::AUTH_SERVER, |
11651 origin, BoundNetLog()); | 11653 empty_ssl_info, origin, BoundNetLog()); |
11652 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER); | 11654 auth_factory->AddMockHandler(auth_handler, HttpAuth::AUTH_SERVER); |
11653 | 11655 |
11654 int rv = OK; | 11656 int rv = OK; |
11655 const HttpResponseInfo* response = NULL; | 11657 const HttpResponseInfo* response = NULL; |
11656 HttpRequestInfo request; | 11658 HttpRequestInfo request; |
11657 request.method = "GET"; | 11659 request.method = "GET"; |
11658 request.url = origin; | 11660 request.url = origin; |
11659 request.load_flags = 0; | 11661 request.load_flags = 0; |
11660 | 11662 |
11661 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 11663 scoped_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
(...skipping 4288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15950 base::MessageLoop::current()->RunUntilIdle(); | 15952 base::MessageLoop::current()->RunUntilIdle(); |
15951 | 15953 |
15952 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 15954 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
15953 HttpRequestHeaders headers; | 15955 HttpRequestHeaders headers; |
15954 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 15956 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
15955 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 15957 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
15956 } | 15958 } |
15957 #endif // !defined(OS_IOS) | 15959 #endif // !defined(OS_IOS) |
15958 | 15960 |
15959 } // namespace net | 15961 } // namespace net |
OLD | NEW |