OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 831 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
832 | 832 |
833 SendRequestAndExpectHttpResponse("hello from http"); | 833 SendRequestAndExpectHttpResponse("hello from http"); |
834 | 834 |
835 ExpectBrokenAlternateProtocolMapping(); | 835 ExpectBrokenAlternateProtocolMapping(); |
836 | 836 |
837 EXPECT_TRUE(quic_data.at_read_eof()); | 837 EXPECT_TRUE(quic_data.at_read_eof()); |
838 EXPECT_TRUE(quic_data.at_write_eof()); | 838 EXPECT_TRUE(quic_data.at_write_eof()); |
839 } | 839 } |
840 | 840 |
| 841 TEST_P(QuicNetworkTransactionTest, ConnectionCloseDuringConnect) { |
| 842 HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too. |
| 843 |
| 844 QuicStreamId stream_id = GetParam() > QUIC_VERSION_12 ? 5 : 3; |
| 845 MockQuicData mock_quic_data; |
| 846 mock_quic_data.AddRead(ConstructConnectionClosePacket(1)); |
| 847 if (GetParam() > QUIC_VERSION_12) { |
| 848 mock_quic_data.AddWrite( |
| 849 ConstructRequestHeadersPacket(1, stream_id, true, true, |
| 850 GetRequestHeaders("GET", "http", "/"))); |
| 851 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
| 852 } else { |
| 853 mock_quic_data.AddWrite( |
| 854 ConstructDataPacket(1, stream_id, true, true, 0, |
| 855 GetRequestString("GET", "http", "/"))); |
| 856 mock_quic_data.AddWrite(ConstructAckPacket(1, 0)); |
| 857 } |
| 858 mock_quic_data.AddDelayedSocketDataToFactory(&socket_factory_, 0); |
| 859 |
| 860 // When the QUIC connection fails, we will try the request again over HTTP. |
| 861 MockRead http_reads[] = { |
| 862 MockRead("HTTP/1.1 200 OK\r\n"), |
| 863 MockRead(kQuicAlternateProtocolHttpHeader), |
| 864 MockRead("hello world"), |
| 865 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 866 MockRead(ASYNC, OK) |
| 867 }; |
| 868 |
| 869 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), |
| 870 NULL, 0); |
| 871 socket_factory_.AddSocketDataProvider(&http_data); |
| 872 |
| 873 // In order for a new QUIC session to be established via alternate-protocol |
| 874 // without racing an HTTP connection, we need the host resolution to happen |
| 875 // synchronously. |
| 876 host_resolver_.set_synchronous_mode(true); |
| 877 host_resolver_.rules()->AddIPLiteralRule("www.google.com", "192.168.0.1", ""); |
| 878 HostResolver::RequestInfo info(HostPortPair("www.google.com", 80)); |
| 879 AddressList address; |
| 880 host_resolver_.Resolve(info, |
| 881 DEFAULT_PRIORITY, |
| 882 &address, |
| 883 CompletionCallback(), |
| 884 NULL, |
| 885 net_log_.bound()); |
| 886 |
| 887 CreateSession(); |
| 888 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 889 SendRequestAndExpectHttpResponse("hello world"); |
| 890 } |
| 891 |
841 } // namespace test | 892 } // namespace test |
842 } // namespace net | 893 } // namespace net |
OLD | NEW |