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 6024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6035 std::string response_data; | 6035 std::string response_data; |
6036 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 6036 ASSERT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
6037 EXPECT_EQ("hello world", response_data); | 6037 EXPECT_EQ("hello world", response_data); |
6038 | 6038 |
6039 EXPECT_FALSE(response->was_fetched_via_spdy); | 6039 EXPECT_FALSE(response->was_fetched_via_spdy); |
6040 EXPECT_TRUE(response->was_npn_negotiated); | 6040 EXPECT_TRUE(response->was_npn_negotiated); |
6041 | 6041 |
6042 HttpNetworkTransaction::SetNextProtos(""); | 6042 HttpNetworkTransaction::SetNextProtos(""); |
6043 HttpNetworkTransaction::SetUseAlternateProtocols(false); | 6043 HttpNetworkTransaction::SetUseAlternateProtocols(false); |
6044 } | 6044 } |
| 6045 |
| 6046 TEST_F(HttpNetworkTransactionTest, SpdyPostNPNServerHangup) { |
| 6047 // Simulate the SSL handshake completing with an NPN negotiation |
| 6048 // followed by an immediate server closing of the socket. |
| 6049 // Fix crash: http://crbug.com/46369 |
| 6050 HttpNetworkTransaction::SetUseAlternateProtocols(true); |
| 6051 HttpNetworkTransaction::SetNextProtos( |
| 6052 "\x08http/1.1\x07http1.1\x06spdy/1\x04spdy"); |
| 6053 SessionDependencies session_deps; |
| 6054 |
| 6055 HttpRequestInfo request; |
| 6056 request.method = "GET"; |
| 6057 request.url = GURL("https://www.google.com/"); |
| 6058 request.load_flags = 0; |
| 6059 |
| 6060 SSLSocketDataProvider ssl(true, OK); |
| 6061 ssl.next_proto_status = SSLClientSocket::kNextProtoNegotiated; |
| 6062 ssl.next_proto = "spdy/1"; |
| 6063 ssl.was_npn_negotiated = true; |
| 6064 session_deps.socket_factory.AddSSLSocketDataProvider(&ssl); |
| 6065 |
| 6066 MockWrite spdy_writes[] = { |
| 6067 MockWrite(true, reinterpret_cast<const char*>(kGetSyn), |
| 6068 arraysize(kGetSyn)), |
| 6069 }; |
| 6070 |
| 6071 MockRead spdy_reads[] = { |
| 6072 MockRead(false, 0, 0) // Not async - return 0 immediately. |
| 6073 }; |
| 6074 |
| 6075 scoped_refptr<DelayedSocketData> spdy_data( |
| 6076 new DelayedSocketData( |
| 6077 0, // don't wait in this case, immediate hangup. |
| 6078 spdy_reads, arraysize(spdy_reads), |
| 6079 spdy_writes, arraysize(spdy_writes))); |
| 6080 session_deps.socket_factory.AddSocketDataProvider(spdy_data); |
| 6081 |
| 6082 TestCompletionCallback callback; |
| 6083 |
| 6084 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps)); |
| 6085 scoped_ptr<HttpNetworkTransaction> trans(new HttpNetworkTransaction(session)); |
| 6086 |
| 6087 int rv = trans->Start(&request, &callback, BoundNetLog()); |
| 6088 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 6089 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
| 6090 |
| 6091 HttpNetworkTransaction::SetNextProtos(""); |
| 6092 HttpNetworkTransaction::SetUseAlternateProtocols(false); |
| 6093 } |
6045 } // namespace net | 6094 } // namespace net |
OLD | NEW |