OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 4908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4919 alternate_protocols.HasAlternateProtocolFor(http_host_port_pair)); | 4919 alternate_protocols.HasAlternateProtocolFor(http_host_port_pair)); |
4920 | 4920 |
4921 EXPECT_EQ(OK, callback.WaitForResult()); | 4921 EXPECT_EQ(OK, callback.WaitForResult()); |
4922 | 4922 |
4923 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4923 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4924 ASSERT_TRUE(response != NULL); | 4924 ASSERT_TRUE(response != NULL); |
4925 ASSERT_TRUE(response->headers != NULL); | 4925 ASSERT_TRUE(response->headers != NULL); |
4926 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4926 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
4927 EXPECT_FALSE(response->was_fetched_via_spdy); | 4927 EXPECT_FALSE(response->was_fetched_via_spdy); |
4928 EXPECT_FALSE(response->was_npn_negotiated); | 4928 EXPECT_FALSE(response->was_npn_negotiated); |
| 4929 EXPECT_FALSE(response->was_alternate_protocol_available); |
4929 | 4930 |
4930 std::string response_data; | 4931 std::string response_data; |
4931 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 4932 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
4932 EXPECT_EQ("hello world", response_data); | 4933 EXPECT_EQ("hello world", response_data); |
4933 | 4934 |
4934 ASSERT_TRUE(alternate_protocols.HasAlternateProtocolFor(http_host_port_pair)); | 4935 ASSERT_TRUE(alternate_protocols.HasAlternateProtocolFor(http_host_port_pair)); |
4935 const HttpAlternateProtocols::PortProtocolPair alternate = | 4936 const HttpAlternateProtocols::PortProtocolPair alternate = |
4936 alternate_protocols.GetAlternateProtocolFor(http_host_port_pair); | 4937 alternate_protocols.GetAlternateProtocolFor(http_host_port_pair); |
4937 HttpAlternateProtocols::PortProtocolPair expected_alternate; | 4938 HttpAlternateProtocols::PortProtocolPair expected_alternate; |
4938 expected_alternate.port = 443; | 4939 expected_alternate.port = 443; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5188 rv = trans->Start(&request, &callback, BoundNetLog()); | 5189 rv = trans->Start(&request, &callback, BoundNetLog()); |
5189 EXPECT_EQ(ERR_IO_PENDING, rv); | 5190 EXPECT_EQ(ERR_IO_PENDING, rv); |
5190 EXPECT_EQ(OK, callback.WaitForResult()); | 5191 EXPECT_EQ(OK, callback.WaitForResult()); |
5191 | 5192 |
5192 response = trans->GetResponseInfo(); | 5193 response = trans->GetResponseInfo(); |
5193 ASSERT_TRUE(response != NULL); | 5194 ASSERT_TRUE(response != NULL); |
5194 ASSERT_TRUE(response->headers != NULL); | 5195 ASSERT_TRUE(response->headers != NULL); |
5195 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 5196 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
5196 EXPECT_TRUE(response->was_fetched_via_spdy); | 5197 EXPECT_TRUE(response->was_fetched_via_spdy); |
5197 EXPECT_TRUE(response->was_npn_negotiated); | 5198 EXPECT_TRUE(response->was_npn_negotiated); |
| 5199 EXPECT_TRUE(response->was_alternate_protocol_available); |
5198 | 5200 |
5199 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 5201 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
5200 EXPECT_EQ("hello!", response_data); | 5202 EXPECT_EQ("hello!", response_data); |
5201 | 5203 |
5202 HttpNetworkTransaction::SetNextProtos(""); | 5204 HttpNetworkTransaction::SetNextProtos(""); |
5203 HttpNetworkTransaction::SetUseAlternateProtocols(false); | 5205 HttpNetworkTransaction::SetUseAlternateProtocols(false); |
5204 } | 5206 } |
5205 | 5207 |
5206 class CapturingProxyResolver : public ProxyResolver { | 5208 class CapturingProxyResolver : public ProxyResolver { |
5207 public: | 5209 public: |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5428 rv = trans->Start(&request, &callback, BoundNetLog()); | 5430 rv = trans->Start(&request, &callback, BoundNetLog()); |
5429 EXPECT_EQ(ERR_IO_PENDING, rv); | 5431 EXPECT_EQ(ERR_IO_PENDING, rv); |
5430 EXPECT_EQ(OK, callback.WaitForResult()); | 5432 EXPECT_EQ(OK, callback.WaitForResult()); |
5431 | 5433 |
5432 response = trans->GetResponseInfo(); | 5434 response = trans->GetResponseInfo(); |
5433 ASSERT_TRUE(response != NULL); | 5435 ASSERT_TRUE(response != NULL); |
5434 ASSERT_TRUE(response->headers != NULL); | 5436 ASSERT_TRUE(response->headers != NULL); |
5435 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 5437 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
5436 EXPECT_TRUE(response->was_fetched_via_spdy); | 5438 EXPECT_TRUE(response->was_fetched_via_spdy); |
5437 EXPECT_TRUE(response->was_npn_negotiated); | 5439 EXPECT_TRUE(response->was_npn_negotiated); |
| 5440 EXPECT_TRUE(response->was_alternate_protocol_available); |
5438 | 5441 |
5439 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 5442 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
5440 EXPECT_EQ("hello!", response_data); | 5443 EXPECT_EQ("hello!", response_data); |
5441 | 5444 |
5442 HttpNetworkTransaction::SetNextProtos(""); | 5445 HttpNetworkTransaction::SetNextProtos(""); |
5443 HttpNetworkTransaction::SetUseAlternateProtocols(false); | 5446 HttpNetworkTransaction::SetUseAlternateProtocols(false); |
5444 } | 5447 } |
5445 | 5448 |
5446 // Tests that ResolveCanonicalName is handled correctly by the | 5449 // Tests that ResolveCanonicalName is handled correctly by the |
5447 // HttpNetworkTransaction. | 5450 // HttpNetworkTransaction. |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6085 ASSERT_TRUE(response != NULL); | 6088 ASSERT_TRUE(response != NULL); |
6086 ASSERT_TRUE(response->headers != NULL); | 6089 ASSERT_TRUE(response->headers != NULL); |
6087 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6090 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
6088 | 6091 |
6089 std::string response_data; | 6092 std::string response_data; |
6090 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 6093 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
6091 EXPECT_EQ("hello world", response_data); | 6094 EXPECT_EQ("hello world", response_data); |
6092 | 6095 |
6093 EXPECT_FALSE(response->was_fetched_via_spdy); | 6096 EXPECT_FALSE(response->was_fetched_via_spdy); |
6094 EXPECT_TRUE(response->was_npn_negotiated); | 6097 EXPECT_TRUE(response->was_npn_negotiated); |
| 6098 EXPECT_FALSE(response->was_alternate_protocol_available); |
6095 | 6099 |
6096 HttpNetworkTransaction::SetNextProtos(""); | 6100 HttpNetworkTransaction::SetNextProtos(""); |
6097 HttpNetworkTransaction::SetUseAlternateProtocols(false); | 6101 HttpNetworkTransaction::SetUseAlternateProtocols(false); |
6098 } | 6102 } |
6099 | 6103 |
6100 TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { | 6104 TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { |
6101 // Simulate the SSL handshake completing with an NPN negotiation | 6105 // Simulate the SSL handshake completing with an NPN negotiation |
6102 // followed by an immediate server closing of the socket. | 6106 // followed by an immediate server closing of the socket. |
6103 // Fix crash: http://crbug.com/46369 | 6107 // Fix crash: http://crbug.com/46369 |
6104 HttpNetworkTransaction::SetUseAlternateProtocols(true); | 6108 HttpNetworkTransaction::SetUseAlternateProtocols(true); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6139 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); | 6143 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
6140 | 6144 |
6141 int rv = trans->Start(&request, &callback, BoundNetLog()); | 6145 int rv = trans->Start(&request, &callback, BoundNetLog()); |
6142 EXPECT_EQ(ERR_IO_PENDING, rv); | 6146 EXPECT_EQ(ERR_IO_PENDING, rv); |
6143 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); | 6147 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
6144 | 6148 |
6145 HttpNetworkTransaction::SetNextProtos(""); | 6149 HttpNetworkTransaction::SetNextProtos(""); |
6146 HttpNetworkTransaction::SetUseAlternateProtocols(false); | 6150 HttpNetworkTransaction::SetUseAlternateProtocols(false); |
6147 } | 6151 } |
6148 } // namespace net | 6152 } // namespace net |
OLD | NEW |