Chromium Code Reviews| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 | 400 |
| 401 // Original socket limits. Some tests set these. Safest to always restore | 401 // Original socket limits. Some tests set these. Safest to always restore |
| 402 // them once each test has been run. | 402 // them once each test has been run. |
| 403 int old_max_group_sockets_; | 403 int old_max_group_sockets_; |
| 404 int old_max_pool_sockets_; | 404 int old_max_pool_sockets_; |
| 405 }; | 405 }; |
| 406 | 406 |
| 407 INSTANTIATE_TEST_CASE_P( | 407 INSTANTIATE_TEST_CASE_P( |
| 408 NextProto, | 408 NextProto, |
| 409 HttpNetworkTransactionTest, | 409 HttpNetworkTransactionTest, |
| 410 testing::Values(kProtoDeprecatedSPDY2, | 410 testing::Values(kProtoSPDY31, kProtoSPDY4)); |
| 411 kProtoSPDY3, kProtoSPDY31, kProtoSPDY4)); | |
| 412 | 411 |
| 413 namespace { | 412 namespace { |
| 414 | 413 |
| 415 class BeforeNetworkStartHandler { | 414 class BeforeNetworkStartHandler { |
| 416 public: | 415 public: |
| 417 explicit BeforeNetworkStartHandler(bool defer) | 416 explicit BeforeNetworkStartHandler(bool defer) |
| 418 : defer_on_before_network_start_(defer), | 417 : defer_on_before_network_start_(defer), |
| 419 observed_before_network_start_(false) {} | 418 observed_before_network_start_(false) {} |
| 420 | 419 |
| 421 void OnBeforeNetworkStart(bool* defer) { | 420 void OnBeforeNetworkStart(bool* defer) { |
| (...skipping 9679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10101 // First round goes unauthenticated through the proxy. | 10100 // First round goes unauthenticated through the proxy. |
| 10102 MockWrite data_writes_1[] = { | 10101 MockWrite data_writes_1[] = { |
| 10103 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" | 10102 MockWrite("GET http://www.google.com/ HTTP/1.1\r\n" |
| 10104 "Host: www.google.com\r\n" | 10103 "Host: www.google.com\r\n" |
| 10105 "Proxy-Connection: keep-alive\r\n" | 10104 "Proxy-Connection: keep-alive\r\n" |
| 10106 "\r\n"), | 10105 "\r\n"), |
| 10107 }; | 10106 }; |
| 10108 MockRead data_reads_1[] = { | 10107 MockRead data_reads_1[] = { |
| 10109 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 10108 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 10110 MockRead("HTTP/1.1 200 OK\r\n" | 10109 MockRead("HTTP/1.1 200 OK\r\n" |
| 10111 "Alternate-Protocol: 443:npn-spdy/2\r\n" | 10110 "Alternate-Protocol: 443:npn-spdy/3.1\r\n" |
|
asanka
2014/11/10 19:18:37
Should this be parameterized as well? I.e. compose
Bence
2014/11/10 22:52:09
Done.
| |
| 10112 "Proxy-Connection: close\r\n" | 10111 "Proxy-Connection: close\r\n" |
| 10113 "\r\n"), | 10112 "\r\n"), |
| 10114 }; | 10113 }; |
| 10115 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), | 10114 StaticSocketDataProvider data_1(data_reads_1, arraysize(data_reads_1), |
| 10116 data_writes_1, arraysize(data_writes_1)); | 10115 data_writes_1, arraysize(data_writes_1)); |
| 10117 | 10116 |
| 10118 // Second round tries to tunnel to www.google.com due to the | 10117 // Second round tries to tunnel to www.google.com due to the |
| 10119 // Alternate-Protocol announcement in the first round. It fails due | 10118 // Alternate-Protocol announcement in the first round. It fails due |
| 10120 // to a proxy authentication challenge. | 10119 // to a proxy authentication challenge. |
| 10121 // After the failure, a tunnel is established to www.google.com using | 10120 // After the failure, a tunnel is established to www.google.com using |
| (...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11395 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, | 11394 scoped_ptr<SpdyFrame> connect(spdy_util_.ConstructSpdyConnect(NULL, 0, 1, |
| 11396 LOWEST)); | 11395 LOWEST)); |
| 11397 scoped_ptr<SpdyFrame> req1( | 11396 scoped_ptr<SpdyFrame> req1( |
| 11398 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); | 11397 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); |
| 11399 scoped_ptr<SpdyFrame> wrapped_req1( | 11398 scoped_ptr<SpdyFrame> wrapped_req1( |
| 11400 spdy_util_.ConstructWrappedSpdyFrame(req1, 1)); | 11399 spdy_util_.ConstructWrappedSpdyFrame(req1, 1)); |
| 11401 | 11400 |
| 11402 // SPDY GET for HTTP URL (through the proxy, but not the tunnel). | 11401 // SPDY GET for HTTP URL (through the proxy, but not the tunnel). |
| 11403 SpdyHeaderBlock req2_block; | 11402 SpdyHeaderBlock req2_block; |
| 11404 req2_block[spdy_util_.GetMethodKey()] = "GET"; | 11403 req2_block[spdy_util_.GetMethodKey()] = "GET"; |
| 11405 req2_block[spdy_util_.GetPathKey()] = | 11404 req2_block[spdy_util_.GetPathKey()] = "/"; |
| 11406 spdy_util_.is_spdy2() ? http_url.c_str() : "/"; | |
| 11407 req2_block[spdy_util_.GetHostKey()] = "www.google.com:443"; | 11405 req2_block[spdy_util_.GetHostKey()] = "www.google.com:443"; |
| 11408 req2_block[spdy_util_.GetSchemeKey()] = "http"; | 11406 req2_block[spdy_util_.GetSchemeKey()] = "http"; |
| 11409 spdy_util_.MaybeAddVersionHeader(&req2_block); | 11407 spdy_util_.MaybeAddVersionHeader(&req2_block); |
| 11410 scoped_ptr<SpdyFrame> req2( | 11408 scoped_ptr<SpdyFrame> req2( |
| 11411 spdy_util_.ConstructSpdySyn(3, req2_block, MEDIUM, false, true)); | 11409 spdy_util_.ConstructSpdySyn(3, req2_block, MEDIUM, false, true)); |
| 11412 | 11410 |
| 11413 MockWrite writes1[] = { | 11411 MockWrite writes1[] = { |
| 11414 CreateMockWrite(*connect, 0), | 11412 CreateMockWrite(*connect, 0), |
| 11415 CreateMockWrite(*wrapped_req1, 2), | 11413 CreateMockWrite(*wrapped_req1, 2), |
| 11416 CreateMockWrite(*req2, 5), | 11414 CreateMockWrite(*req2, 5), |
| (...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 13181 EXPECT_EQ(ERR_IO_PENDING, rv); | 13179 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 13182 | 13180 |
| 13183 rv = callback.WaitForResult(); | 13181 rv = callback.WaitForResult(); |
| 13184 EXPECT_EQ(ERR_CONNECTION_RESET, rv); | 13182 EXPECT_EQ(ERR_CONNECTION_RESET, rv); |
| 13185 | 13183 |
| 13186 const HttpResponseInfo* response = trans->GetResponseInfo(); | 13184 const HttpResponseInfo* response = trans->GetResponseInfo(); |
| 13187 EXPECT_TRUE(response == NULL); | 13185 EXPECT_TRUE(response == NULL); |
| 13188 } | 13186 } |
| 13189 | 13187 |
| 13190 } // namespace net | 13188 } // namespace net |
| OLD | NEW |