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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 // The non-alternate protocol job needs to hang in order to guarantee that | 520 // The non-alternate protocol job needs to hang in order to guarantee that |
521 // the alternate-protocol job will "win". | 521 // the alternate-protocol job will "win". |
522 AddHangingNonAlternateProtocolSocketData(); | 522 AddHangingNonAlternateProtocolSocketData(); |
523 | 523 |
524 CreateSessionWithNextProtos(); | 524 CreateSessionWithNextProtos(); |
525 | 525 |
526 SendRequestAndExpectHttpResponse("hello world"); | 526 SendRequestAndExpectHttpResponse("hello world"); |
527 SendRequestAndExpectQuicResponse("hello!"); | 527 SendRequestAndExpectQuicResponse("hello!"); |
528 } | 528 } |
529 | 529 |
| 530 TEST_P(QuicNetworkTransactionTest, ConfirmAlternativeService) { |
| 531 MockRead http_reads[] = { |
| 532 MockRead("HTTP/1.1 200 OK\r\n"), |
| 533 MockRead(kQuicAlternateProtocolHttpHeader), |
| 534 MockRead("hello world"), |
| 535 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 536 MockRead(ASYNC, OK)}; |
| 537 |
| 538 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, |
| 539 0); |
| 540 socket_factory_.AddSocketDataProvider(&http_data); |
| 541 |
| 542 MockQuicData mock_quic_data; |
| 543 mock_quic_data.AddWrite( |
| 544 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, |
| 545 GetRequestHeaders("GET", "http", "/"))); |
| 546 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
| 547 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 548 mock_quic_data.AddRead( |
| 549 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
| 550 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
| 551 mock_quic_data.AddRead(SYNCHRONOUS, 0); // EOF |
| 552 |
| 553 mock_quic_data.AddDelayedSocketDataToFactory(&socket_factory_, 1); |
| 554 |
| 555 // The non-alternate protocol job needs to hang in order to guarantee that |
| 556 // the alternate-protocol job will "win". |
| 557 AddHangingNonAlternateProtocolSocketData(); |
| 558 |
| 559 CreateSessionWithNextProtos(); |
| 560 |
| 561 AlternativeService alternative_service(QUIC, |
| 562 HostPortPair::FromURL(request_.url)); |
| 563 session_->http_server_properties()->MarkAlternativeServiceRecentlyBroken( |
| 564 alternative_service); |
| 565 EXPECT_TRUE( |
| 566 session_->http_server_properties()->WasAlternativeServiceRecentlyBroken( |
| 567 alternative_service)); |
| 568 |
| 569 SendRequestAndExpectHttpResponse("hello world"); |
| 570 SendRequestAndExpectQuicResponse("hello!"); |
| 571 |
| 572 EXPECT_FALSE( |
| 573 session_->http_server_properties()->WasAlternativeServiceRecentlyBroken( |
| 574 alternative_service)); |
| 575 } |
| 576 |
530 TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolProbabilityForQuic) { | 577 TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolProbabilityForQuic) { |
531 MockRead http_reads[] = { | 578 MockRead http_reads[] = { |
532 MockRead("HTTP/1.1 200 OK\r\n"), | 579 MockRead("HTTP/1.1 200 OK\r\n"), |
533 MockRead(kQuicAlternateProtocol50pctHttpHeader), | 580 MockRead(kQuicAlternateProtocol50pctHttpHeader), |
534 MockRead("hello world"), | 581 MockRead("hello world"), |
535 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 582 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
536 MockRead(ASYNC, OK) | 583 MockRead(ASYNC, OK) |
537 }; | 584 }; |
538 | 585 |
539 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), | 586 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 nullptr, | 1114 nullptr, |
1068 net_log_.bound()); | 1115 net_log_.bound()); |
1069 | 1116 |
1070 CreateSessionWithNextProtos(); | 1117 CreateSessionWithNextProtos(); |
1071 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 1118 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
1072 SendRequestAndExpectHttpResponse("hello world"); | 1119 SendRequestAndExpectHttpResponse("hello world"); |
1073 } | 1120 } |
1074 | 1121 |
1075 } // namespace test | 1122 } // namespace test |
1076 } // namespace net | 1123 } // namespace net |
OLD | NEW |