| 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 12277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12288 request.method = "GET"; | 12288 request.method = "GET"; |
| 12289 request.url = GURL(test_config.server_url); | 12289 request.url = GURL(test_config.server_url); |
| 12290 | 12290 |
| 12291 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 12291 std::unique_ptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
| 12292 | 12292 |
| 12293 SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK); | 12293 SSLSocketDataProvider ssl_socket_data_provider(SYNCHRONOUS, OK); |
| 12294 | 12294 |
| 12295 std::vector<std::vector<MockRead>> mock_reads(1); | 12295 std::vector<std::vector<MockRead>> mock_reads(1); |
| 12296 std::vector<std::vector<MockWrite>> mock_writes(1); | 12296 std::vector<std::vector<MockWrite>> mock_writes(1); |
| 12297 for (int round = 0; round < test_config.num_auth_rounds; ++round) { | 12297 for (int round = 0; round < test_config.num_auth_rounds; ++round) { |
| 12298 SCOPED_TRACE(round); |
| 12298 const TestRound& read_write_round = test_config.rounds[round]; | 12299 const TestRound& read_write_round = test_config.rounds[round]; |
| 12299 | 12300 |
| 12300 // Set up expected reads and writes. | 12301 // Set up expected reads and writes. |
| 12301 mock_reads.back().push_back(read_write_round.read); | 12302 mock_reads.back().push_back(read_write_round.read); |
| 12302 mock_writes.back().push_back(read_write_round.write); | 12303 mock_writes.back().push_back(read_write_round.write); |
| 12303 | 12304 |
| 12304 // kProxyChallenge uses Proxy-Connection: close which means that the | 12305 // kProxyChallenge uses Proxy-Connection: close which means that the |
| 12305 // socket is closed and a new one will be created for the next request. | 12306 // socket is closed and a new one will be created for the next request. |
| 12306 if (read_write_round.read.data == kProxyChallenge.data) { | 12307 if (read_write_round.read.data == kProxyChallenge.data) { |
| 12307 mock_reads.push_back(std::vector<MockRead>()); | 12308 mock_reads.push_back(std::vector<MockRead>()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 12328 mock_writes[i].size()))); | 12329 mock_writes[i].size()))); |
| 12329 session_deps_.socket_factory->AddSocketDataProvider( | 12330 session_deps_.socket_factory->AddSocketDataProvider( |
| 12330 data_providers.back().get()); | 12331 data_providers.back().get()); |
| 12331 } | 12332 } |
| 12332 | 12333 |
| 12333 // Transaction must be created after DataProviders, so it's destroyed before | 12334 // Transaction must be created after DataProviders, so it's destroyed before |
| 12334 // they are as well. | 12335 // they are as well. |
| 12335 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); | 12336 HttpNetworkTransaction trans(DEFAULT_PRIORITY, session.get()); |
| 12336 | 12337 |
| 12337 for (int round = 0; round < test_config.num_auth_rounds; ++round) { | 12338 for (int round = 0; round < test_config.num_auth_rounds; ++round) { |
| 12339 SCOPED_TRACE(round); |
| 12338 const TestRound& read_write_round = test_config.rounds[round]; | 12340 const TestRound& read_write_round = test_config.rounds[round]; |
| 12339 // Start or restart the transaction. | 12341 // Start or restart the transaction. |
| 12340 TestCompletionCallback callback; | 12342 TestCompletionCallback callback; |
| 12341 int rv; | 12343 int rv; |
| 12342 if (round == 0) { | 12344 if (round == 0) { |
| 12343 rv = trans.Start(&request, callback.callback(), NetLogWithSource()); | 12345 rv = trans.Start(&request, callback.callback(), NetLogWithSource()); |
| 12344 } else { | 12346 } else { |
| 12345 rv = trans.RestartWithAuth( | 12347 rv = trans.RestartWithAuth( |
| 12346 AuthCredentials(kFoo, kBar), callback.callback()); | 12348 AuthCredentials(kFoo, kBar), callback.callback()); |
| 12347 } | 12349 } |
| (...skipping 4377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16725 TEST_F(HttpNetworkTransactionTest, MatchContentEncoding2) { | 16727 TEST_F(HttpNetworkTransactionTest, MatchContentEncoding2) { |
| 16726 CheckContentEncodingMatching(&session_deps_, "identity;q=1, *;q=0", "", true); | 16728 CheckContentEncodingMatching(&session_deps_, "identity;q=1, *;q=0", "", true); |
| 16727 } | 16729 } |
| 16728 | 16730 |
| 16729 TEST_F(HttpNetworkTransactionTest, MatchContentEncoding3) { | 16731 TEST_F(HttpNetworkTransactionTest, MatchContentEncoding3) { |
| 16730 CheckContentEncodingMatching(&session_deps_, "identity;q=1, *;q=0", "gzip", | 16732 CheckContentEncodingMatching(&session_deps_, "identity;q=1, *;q=0", "gzip", |
| 16731 false); | 16733 false); |
| 16732 } | 16734 } |
| 16733 | 16735 |
| 16734 } // namespace net | 16736 } // namespace net |
| OLD | NEW |