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