| 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 3939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3950 "Content-Length: 1\r\n\r\n"; | 3950 "Content-Length: 1\r\n\r\n"; |
| 3951 scoped_ptr<SpdyFrame> wrapped_get_resp1( | 3951 scoped_ptr<SpdyFrame> wrapped_get_resp1( |
| 3952 spdy_util_.ConstructSpdyBodyFrame(1, resp1, strlen(resp1), false)); | 3952 spdy_util_.ConstructSpdyBodyFrame(1, resp1, strlen(resp1), false)); |
| 3953 scoped_ptr<SpdyFrame> wrapped_body1( | 3953 scoped_ptr<SpdyFrame> wrapped_body1( |
| 3954 spdy_util_.ConstructSpdyBodyFrame(1, "1", 1, false)); | 3954 spdy_util_.ConstructSpdyBodyFrame(1, "1", 1, false)); |
| 3955 scoped_ptr<SpdyFrame> window_update( | 3955 scoped_ptr<SpdyFrame> window_update( |
| 3956 spdy_util_.ConstructSpdyWindowUpdate(1, wrapped_get_resp1->size())); | 3956 spdy_util_.ConstructSpdyWindowUpdate(1, wrapped_get_resp1->size())); |
| 3957 | 3957 |
| 3958 // CONNECT to mail.example.org:443 via SPDY. | 3958 // CONNECT to mail.example.org:443 via SPDY. |
| 3959 SpdyHeaderBlock connect2_block; | 3959 SpdyHeaderBlock connect2_block; |
| 3960 spdy_util_.MaybeAddVersionHeader(&connect2_block); |
| 3960 connect2_block[spdy_util_.GetMethodKey()] = "CONNECT"; | 3961 connect2_block[spdy_util_.GetMethodKey()] = "CONNECT"; |
| 3961 if (GetParam() == kProtoHTTP2) { | 3962 if (GetParam() == kProtoHTTP2) { |
| 3962 connect2_block[spdy_util_.GetHostKey()] = "mail.example.org:443"; | 3963 connect2_block[spdy_util_.GetHostKey()] = "mail.example.org:443"; |
| 3963 } else { | 3964 } else { |
| 3965 connect2_block[spdy_util_.GetHostKey()] = "mail.example.org"; |
| 3964 connect2_block[spdy_util_.GetPathKey()] = "mail.example.org:443"; | 3966 connect2_block[spdy_util_.GetPathKey()] = "mail.example.org:443"; |
| 3965 connect2_block[spdy_util_.GetHostKey()] = "mail.example.org"; | |
| 3966 } | 3967 } |
| 3967 spdy_util_.MaybeAddVersionHeader(&connect2_block); | |
| 3968 scoped_ptr<SpdyFrame> connect2( | 3968 scoped_ptr<SpdyFrame> connect2( |
| 3969 spdy_util_.ConstructSpdySyn(3, connect2_block, LOWEST, false, false)); | 3969 spdy_util_.ConstructSpdySyn(3, connect2_block, LOWEST, false, false)); |
| 3970 | 3970 |
| 3971 scoped_ptr<SpdyFrame> conn_resp2( | 3971 scoped_ptr<SpdyFrame> conn_resp2( |
| 3972 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); | 3972 spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); |
| 3973 | 3973 |
| 3974 // Fetch https://mail.example.org/ via HTTP. | 3974 // Fetch https://mail.example.org/ via HTTP. |
| 3975 const char get2[] = | 3975 const char get2[] = |
| 3976 "GET / HTTP/1.1\r\n" | 3976 "GET / HTTP/1.1\r\n" |
| 3977 "Host: mail.example.org\r\n" | 3977 "Host: mail.example.org\r\n" |
| (...skipping 8619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12597 const HostPortPair host_port_pair("www.example.org", 8080); | 12597 const HostPortPair host_port_pair("www.example.org", 8080); |
| 12598 scoped_ptr<SpdyFrame> connect( | 12598 scoped_ptr<SpdyFrame> connect( |
| 12599 spdy_util_.ConstructSpdyConnect(NULL, 0, 1, LOWEST, host_port_pair)); | 12599 spdy_util_.ConstructSpdyConnect(NULL, 0, 1, LOWEST, host_port_pair)); |
| 12600 scoped_ptr<SpdyFrame> req1( | 12600 scoped_ptr<SpdyFrame> req1( |
| 12601 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); | 12601 spdy_util_.ConstructSpdyGet(https_url.c_str(), false, 1, LOWEST)); |
| 12602 scoped_ptr<SpdyFrame> wrapped_req1( | 12602 scoped_ptr<SpdyFrame> wrapped_req1( |
| 12603 spdy_util_.ConstructWrappedSpdyFrame(req1, 1)); | 12603 spdy_util_.ConstructWrappedSpdyFrame(req1, 1)); |
| 12604 | 12604 |
| 12605 // SPDY GET for HTTP URL (through the proxy, but not the tunnel). | 12605 // SPDY GET for HTTP URL (through the proxy, but not the tunnel). |
| 12606 SpdyHeaderBlock req2_block; | 12606 SpdyHeaderBlock req2_block; |
| 12607 spdy_util_.MaybeAddVersionHeader(&req2_block); |
| 12607 req2_block[spdy_util_.GetMethodKey()] = "GET"; | 12608 req2_block[spdy_util_.GetMethodKey()] = "GET"; |
| 12608 req2_block[spdy_util_.GetPathKey()] = "/"; | |
| 12609 req2_block[spdy_util_.GetHostKey()] = "www.example.org:8080"; | 12609 req2_block[spdy_util_.GetHostKey()] = "www.example.org:8080"; |
| 12610 req2_block[spdy_util_.GetSchemeKey()] = "http"; | 12610 req2_block[spdy_util_.GetSchemeKey()] = "http"; |
| 12611 spdy_util_.MaybeAddVersionHeader(&req2_block); | 12611 req2_block[spdy_util_.GetPathKey()] = "/"; |
| 12612 scoped_ptr<SpdyFrame> req2( | 12612 scoped_ptr<SpdyFrame> req2( |
| 12613 spdy_util_.ConstructSpdySyn(3, req2_block, MEDIUM, false, true)); | 12613 spdy_util_.ConstructSpdySyn(3, req2_block, MEDIUM, false, true)); |
| 12614 | 12614 |
| 12615 MockWrite writes1[] = { | 12615 MockWrite writes1[] = { |
| 12616 CreateMockWrite(*connect, 0), | 12616 CreateMockWrite(*connect, 0), |
| 12617 CreateMockWrite(*wrapped_req1, 2), | 12617 CreateMockWrite(*wrapped_req1, 2), |
| 12618 CreateMockWrite(*req2, 5), | 12618 CreateMockWrite(*req2, 5), |
| 12619 }; | 12619 }; |
| 12620 | 12620 |
| 12621 scoped_ptr<SpdyFrame> conn_resp( | 12621 scoped_ptr<SpdyFrame> conn_resp( |
| (...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14721 std::string response_data; | 14721 std::string response_data; |
| 14722 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 14722 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
| 14723 | 14723 |
| 14724 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), | 14724 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), |
| 14725 trans->GetTotalSentBytes()); | 14725 trans->GetTotalSentBytes()); |
| 14726 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)), | 14726 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)), |
| 14727 trans->GetTotalReceivedBytes()); | 14727 trans->GetTotalReceivedBytes()); |
| 14728 } | 14728 } |
| 14729 | 14729 |
| 14730 } // namespace net | 14730 } // namespace net |
| OLD | NEW |