| 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 | 10 |
| (...skipping 12275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12286 request.method = "GET"; | 12286 request.method = "GET"; |
| 12287 request.url = GURL(test_config.server_url); | 12287 request.url = GURL(test_config.server_url); |
| 12288 | 12288 |
| 12289 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12289 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12290 | 12290 |
| 12291 SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK); | 12291 SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK); |
| 12292 | 12292 |
| 12293 std::vector<std::vector<MockRead>> mock_reads(1); | 12293 std::vector<std::vector<MockRead>> mock_reads(1); |
| 12294 std::vector<std::vector<MockWrite>> mock_writes(1); | 12294 std::vector<std::vector<MockWrite>> mock_writes(1); |
| 12295 for (int round = 0; round < test_config.num_auth_rounds; ++round) { | 12295 for (int round = 0; round < test_config.num_auth_rounds; ++round) { |
| 12296 SCOPED_TRACE(round); |
| 12296 const TestRound& read_write_round = test_config.rounds[round]; | 12297 const TestRound& read_write_round = test_config.rounds[round]; |
| 12297 | 12298 |
| 12298 // Set up expected reads and writes. | 12299 // Set up expected reads and writes. |
| 12299 mock_reads.back().push_back(read_write_round.read); | 12300 mock_reads.back().push_back(read_write_round.read); |
| 12300 mock_writes.back().push_back(read_write_round.write); | 12301 mock_writes.back().push_back(read_write_round.write); |
| 12301 | 12302 |
| 12302 // kProxyChallenge uses Proxy-Connection: close which means that the | 12303 // kProxyChallenge uses Proxy-Connection: close which means that the |
| 12303 // socket is closed and a new one will be created for the next request. | 12304 // socket is closed and a new one will be created for the next request. |
| 12304 if (read_write_round.read.data == kProxyChallenge.data) { | 12305 if (read_write_round.read.data == kProxyChallenge.data) { |
| 12305 mock_reads.push_back(std::vector<MockRead>()); | 12306 mock_reads.push_back(std::vector<MockRead>()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 12326 mock_writes[i].size()))); | 12327 mock_writes[i].size()))); |
| 12327 session_deps_.socket_factory->AddSocketDataProvider( | 12328 session_deps_.socket_factory->AddSocketDataProvider( |
| 12328 data_providers.back().get()); | 12329 data_providers.back().get()); |
| 12329 } | 12330 } |
| 12330 | 12331 |
| 12331 // Transaction must be created after DataProviders, so it's destroyed before | 12332 // Transaction must be created after DataProviders, so it's destroyed before |
| 12332 // they are as well. | 12333 // they are as well. |
| 12333 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 12334 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 12334 | 12335 |
| 12335 for (int round = 0; round < test_config.num_auth_rounds; ++round) { | 12336 for (int round = 0; round < test_config.num_auth_rounds; ++round) { |
| 12337 SCOPED_TRACE(round); |
| 12336 const TestRound& read_write_round = test_config.rounds[round]; | 12338 const TestRound& read_write_round = test_config.rounds[round]; |
| 12337 // Start or restart the transaction. | 12339 // Start or restart the transaction. |
| 12338 TestCompletionCallback callback; | 12340 TestCompletionCallback callback; |
| 12339 int rv; | 12341 int rv; |
| 12340 if (round == 0) { | 12342 if (round == 0) { |
| 12341 rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 12343 rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
| 12342 } else { | 12344 } else { |
| 12343 rv = trans.RestartWithAuth( | 12345 rv = trans.RestartWithAuth( |
| 12344 AuthCredentials(kFoo, kBar), callback.callback()); | 12346 AuthCredentials(kFoo, kBar), callback.callback()); |
| 12345 } | 12347 } |
| (...skipping 4172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16518 base::RunLoop().RunUntilIdle(); | 16520 base::RunLoop().RunUntilIdle(); |
| 16519 | 16521 |
| 16520 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); | 16522 EXPECT_TRUE(trans.GetResponseInfo()->was_fetched_via_spdy); |
| 16521 HttpRequestHeaders headers; | 16523 HttpRequestHeaders headers; |
| 16522 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); | 16524 ASSERT_TRUE(trans.GetFullRequestHeaders(&headers)); |
| 16523 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); | 16525 EXPECT_TRUE(headers.HasHeader(HttpRequestHeaders::kTokenBinding)); |
| 16524 } | 16526 } |
| 16525 #endif // !defined(OS_IOS) | 16527 #endif // !defined(OS_IOS) |
| 16526 | 16528 |
| 16527 } // namespace net | 16529 } // namespace net |
| OLD | NEW |