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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 &address, | 638 &address, |
639 CompletionCallback(), | 639 CompletionCallback(), |
640 NULL, | 640 NULL, |
641 net_log_.bound()); | 641 net_log_.bound()); |
642 | 642 |
643 CreateSession(); | 643 CreateSession(); |
644 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 644 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
645 SendRequestAndExpectQuicResponse("hello!"); | 645 SendRequestAndExpectQuicResponse("hello!"); |
646 } | 646 } |
647 | 647 |
| 648 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithProxy) { |
| 649 proxy_service_.reset( |
| 650 ProxyService::CreateFixedFromPacResult("PROXY myproxy:70")); |
| 651 HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too. |
| 652 |
| 653 // Since we are using a proxy, the QUIC job will not succeed. |
| 654 MockWrite http_writes[] = { |
| 655 MockWrite(SYNCHRONOUS, 0, "GET http://www.google.com/ HTTP/1.1\r\n"), |
| 656 MockWrite(SYNCHRONOUS, 1, "Host: www.google.com\r\n"), |
| 657 MockWrite(SYNCHRONOUS, 2, "Proxy-Connection: keep-alive\r\n\r\n") |
| 658 }; |
| 659 |
| 660 MockRead http_reads[] = { |
| 661 MockRead(SYNCHRONOUS, 3, "HTTP/1.1 200 OK\r\n"), |
| 662 MockRead(SYNCHRONOUS, 4, kQuicAlternateProtocolHttpHeader), |
| 663 MockRead(SYNCHRONOUS, 5, "hello world"), |
| 664 MockRead(SYNCHRONOUS, OK, 6) |
| 665 }; |
| 666 |
| 667 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), |
| 668 http_writes, arraysize(http_writes)); |
| 669 socket_factory_.AddSocketDataProvider(&http_data); |
| 670 |
| 671 // In order for a new QUIC session to be established via alternate-protocol |
| 672 // without racing an HTTP connection, we need the host resolution to happen |
| 673 // synchronously. |
| 674 host_resolver_.set_synchronous_mode(true); |
| 675 host_resolver_.rules()->AddIPLiteralRule("www.google.com", "192.168.0.1", ""); |
| 676 HostResolver::RequestInfo info(HostPortPair("www.google.com", 80)); |
| 677 AddressList address; |
| 678 host_resolver_.Resolve(info, |
| 679 DEFAULT_PRIORITY, |
| 680 &address, |
| 681 CompletionCallback(), |
| 682 NULL, |
| 683 net_log_.bound()); |
| 684 |
| 685 CreateSession(); |
| 686 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 687 SendRequestAndExpectHttpResponse("hello world"); |
| 688 } |
| 689 |
648 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithConfirmationRequired) { | 690 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithConfirmationRequired) { |
649 HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too. | 691 HttpStreamFactory::EnableNpnSpdy3(); // Enables QUIC too. |
650 | 692 |
651 MockQuicData mock_quic_data; | 693 MockQuicData mock_quic_data; |
652 mock_quic_data.AddWrite( | 694 mock_quic_data.AddWrite( |
653 ConstructRequestHeadersPacket(1, kStreamId5, true, true, | 695 ConstructRequestHeadersPacket(1, kStreamId5, true, true, |
654 GetRequestHeaders("GET", "http", "/"))); | 696 GetRequestHeaders("GET", "http", "/"))); |
655 mock_quic_data.AddRead( | 697 mock_quic_data.AddRead( |
656 ConstructResponseHeadersPacket(1, kStreamId5, false, false, | 698 ConstructResponseHeadersPacket(1, kStreamId5, false, false, |
657 GetResponseHeaders("200 OK"))); | 699 GetResponseHeaders("200 OK"))); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 NULL, | 870 NULL, |
829 net_log_.bound()); | 871 net_log_.bound()); |
830 | 872 |
831 CreateSession(); | 873 CreateSession(); |
832 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 874 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
833 SendRequestAndExpectHttpResponse("hello world"); | 875 SendRequestAndExpectHttpResponse("hello world"); |
834 } | 876 } |
835 | 877 |
836 } // namespace test | 878 } // namespace test |
837 } // namespace net | 879 } // namespace net |
OLD | NEW |