| 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 <memory> | 5 #include <memory> |
| 6 #include <ostream> | 6 #include <ostream> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 GetRequestHeaders("GET", "https", "/"))); | 699 GetRequestHeaders("GET", "https", "/"))); |
| 700 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 700 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 701 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 701 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 702 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 702 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 703 false, true, 0, "hello!")); | 703 false, true, 0, "hello!")); |
| 704 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 704 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 705 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more data to read | 705 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more data to read |
| 706 | 706 |
| 707 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 707 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 708 | 708 |
| 709 // The non-alternate protocol job needs to hang in order to guarantee that |
| 710 // the alternate-protocol job will "win". |
| 711 AddHangingNonAlternateProtocolSocketData(); |
| 712 |
| 709 params_.enable_alternative_service_with_different_host = false; | 713 params_.enable_alternative_service_with_different_host = false; |
| 710 CreateSession(); | 714 CreateSession(); |
| 711 | 715 |
| 712 EXPECT_FALSE( | 716 EXPECT_FALSE( |
| 713 test_socket_performance_watcher_factory_.rtt_notification_received()); | 717 test_socket_performance_watcher_factory_.rtt_notification_received()); |
| 714 SendRequestAndExpectQuicResponse("hello!"); | 718 SendRequestAndExpectQuicResponse("hello!"); |
| 715 EXPECT_TRUE( | 719 EXPECT_TRUE( |
| 716 test_socket_performance_watcher_factory_.rtt_notification_received()); | 720 test_socket_performance_watcher_factory_.rtt_notification_received()); |
| 717 | 721 |
| 718 // Check that the NetLog was filled reasonably. | 722 // Check that the NetLog was filled reasonably. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 EXPECT_TRUE(cert->VerifyNameMatch(proxy_host, &common_name_fallback_used)); | 824 EXPECT_TRUE(cert->VerifyNameMatch(proxy_host, &common_name_fallback_used)); |
| 821 EXPECT_FALSE(cert->VerifyNameMatch(origin_host, &common_name_fallback_used)); | 825 EXPECT_FALSE(cert->VerifyNameMatch(origin_host, &common_name_fallback_used)); |
| 822 ProofVerifyDetailsChromium verify_details; | 826 ProofVerifyDetailsChromium verify_details; |
| 823 verify_details.cert_verify_result.verified_cert = cert; | 827 verify_details.cert_verify_result.verified_cert = cert; |
| 824 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 828 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
| 825 ProofVerifyDetailsChromium verify_details2; | 829 ProofVerifyDetailsChromium verify_details2; |
| 826 verify_details2.cert_verify_result.verified_cert = cert; | 830 verify_details2.cert_verify_result.verified_cert = cert; |
| 827 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); | 831 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); |
| 828 | 832 |
| 829 request_.url = GURL("http://" + origin_host); | 833 request_.url = GURL("http://" + origin_host); |
| 834 AddHangingNonAlternateProtocolSocketData(); |
| 830 CreateSession(); | 835 CreateSession(); |
| 831 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); | 836 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 832 SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 70); | 837 SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 70); |
| 833 } | 838 } |
| 834 | 839 |
| 835 TEST_P(QuicNetworkTransactionTest, AlternativeServicesDifferentHost) { | 840 TEST_P(QuicNetworkTransactionTest, AlternativeServicesDifferentHost) { |
| 836 params_.enable_alternative_service_with_different_host = true; | 841 params_.enable_alternative_service_with_different_host = true; |
| 837 HostPortPair origin("www.example.org", 443); | 842 HostPortPair origin("www.example.org", 443); |
| 838 HostPortPair alternative("mail.example.org", 443); | 843 HostPortPair alternative("mail.example.org", 443); |
| 839 | 844 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 861 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 866 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 862 false, true, 0, "hello!")); | 867 false, true, 0, "hello!")); |
| 863 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 868 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 864 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 869 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 865 mock_quic_data.AddRead(ASYNC, 0); | 870 mock_quic_data.AddRead(ASYNC, 0); |
| 866 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 871 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 867 | 872 |
| 868 request_.url = GURL("https://" + origin.host()); | 873 request_.url = GURL("https://" + origin.host()); |
| 869 AddQuicRemoteAlternativeServiceMapping( | 874 AddQuicRemoteAlternativeServiceMapping( |
| 870 MockCryptoClientStream::CONFIRM_HANDSHAKE, alternative); | 875 MockCryptoClientStream::CONFIRM_HANDSHAKE, alternative); |
| 876 AddHangingNonAlternateProtocolSocketData(); |
| 871 CreateSession(); | 877 CreateSession(); |
| 872 | 878 |
| 873 SendRequestAndExpectQuicResponse("hello!"); | 879 SendRequestAndExpectQuicResponse("hello!"); |
| 874 } | 880 } |
| 875 | 881 |
| 876 TEST_P(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) { | 882 TEST_P(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) { |
| 877 params_.origins_to_force_quic_on.insert( | 883 params_.origins_to_force_quic_on.insert( |
| 878 HostPortPair::FromString("mail.example.org:443")); | 884 HostPortPair::FromString("mail.example.org:443")); |
| 879 | 885 |
| 880 MockQuicData mock_quic_data1; | 886 MockQuicData mock_quic_data1; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 950 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 945 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 951 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 946 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 952 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 947 false, true, 0, "hello!")); | 953 false, true, 0, "hello!")); |
| 948 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 954 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 949 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 955 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 950 mock_quic_data.AddRead(ASYNC, 0); // EOF | 956 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 951 | 957 |
| 952 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 958 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 953 | 959 |
| 960 AddHangingNonAlternateProtocolSocketData(); |
| 954 CreateSession(); | 961 CreateSession(); |
| 955 | 962 |
| 956 SendRequestAndExpectHttpResponse("hello world"); | 963 SendRequestAndExpectHttpResponse("hello world"); |
| 957 SendRequestAndExpectQuicResponse("hello!"); | 964 SendRequestAndExpectQuicResponse("hello!"); |
| 958 } | 965 } |
| 959 | 966 |
| 960 TEST_P(QuicNetworkTransactionTest, | 967 TEST_P(QuicNetworkTransactionTest, |
| 961 UseAlternativeServiceWithProbabilityForQuic) { | 968 UseAlternativeServiceWithProbabilityForQuic) { |
| 962 MockRead http_reads[] = { | 969 MockRead http_reads[] = { |
| 963 MockRead("HTTP/1.1 200 OK\r\n"), | 970 MockRead("HTTP/1.1 200 OK\r\n"), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 978 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 985 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 979 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 986 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 980 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 987 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 981 false, true, 0, "hello!")); | 988 false, true, 0, "hello!")); |
| 982 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 989 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 983 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 990 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 984 mock_quic_data.AddRead(ASYNC, 0); // EOF | 991 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 985 | 992 |
| 986 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 993 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 987 | 994 |
| 995 AddHangingNonAlternateProtocolSocketData(); |
| 988 CreateSession(); | 996 CreateSession(); |
| 989 | 997 |
| 990 SendRequestAndExpectHttpResponse("hello world"); | 998 SendRequestAndExpectHttpResponse("hello world"); |
| 991 SendRequestAndExpectQuicResponse("hello!"); | 999 SendRequestAndExpectQuicResponse("hello!"); |
| 992 } | 1000 } |
| 993 | 1001 |
| 994 TEST_P(QuicNetworkTransactionTest, SetAlternativeServiceWithScheme) { | 1002 TEST_P(QuicNetworkTransactionTest, SetAlternativeServiceWithScheme) { |
| 995 MockRead http_reads[] = { | 1003 MockRead http_reads[] = { |
| 996 MockRead("HTTP/1.1 200 OK\r\n"), | 1004 MockRead("HTTP/1.1 200 OK\r\n"), |
| 997 MockRead("Alt-Svc: quic=\"foo.example.org:443\", quic=\":444\"\r\n\r\n"), | 1005 MockRead("Alt-Svc: quic=\"foo.example.org:443\", quic=\":444\"\r\n\r\n"), |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 1086 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 1079 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1087 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 1080 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 1088 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 1081 false, true, 0, "hello!")); | 1089 false, true, 0, "hello!")); |
| 1082 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 1090 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 1083 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1091 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1084 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1092 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1085 | 1093 |
| 1086 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1094 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1087 | 1095 |
| 1096 AddHangingNonAlternateProtocolSocketData(); |
| 1088 CreateSession(); | 1097 CreateSession(); |
| 1089 | 1098 |
| 1090 SendRequestAndExpectHttpResponse("hello world"); | 1099 SendRequestAndExpectHttpResponse("hello world"); |
| 1091 SendRequestAndExpectQuicResponse("hello!"); | 1100 SendRequestAndExpectQuicResponse("hello!"); |
| 1092 } | 1101 } |
| 1093 | 1102 |
| 1094 TEST_P(QuicNetworkTransactionTest, GoAwayWithConnectionMigrationOnPortsOnly) { | 1103 TEST_P(QuicNetworkTransactionTest, GoAwayWithConnectionMigrationOnPortsOnly) { |
| 1095 MockQuicData mock_quic_data; | 1104 MockQuicData mock_quic_data; |
| 1096 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( | 1105 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( |
| 1097 1, kClientDataStreamId1, true, true, | 1106 1, kClientDataStreamId1, true, true, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 &response_header_offset)); | 1232 &response_header_offset)); |
| 1224 mock_quic_data.AddRead(ConstructServerDataPacket(4, kClientDataStreamId2, | 1233 mock_quic_data.AddRead(ConstructServerDataPacket(4, kClientDataStreamId2, |
| 1225 false, true, 0, "hello!")); | 1234 false, true, 0, "hello!")); |
| 1226 mock_quic_data.AddWrite( | 1235 mock_quic_data.AddWrite( |
| 1227 ConstructClientAckAndConnectionClosePacket(4, 4, 3, 1)); | 1236 ConstructClientAckAndConnectionClosePacket(4, 4, 3, 1)); |
| 1228 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1237 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1229 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1238 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1230 | 1239 |
| 1231 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1240 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1232 | 1241 |
| 1242 AddHangingNonAlternateProtocolSocketData(); |
| 1233 CreateSession(); | 1243 CreateSession(); |
| 1234 | 1244 |
| 1235 SendRequestAndExpectHttpResponse("hello world"); | 1245 SendRequestAndExpectHttpResponse("hello world"); |
| 1236 | 1246 |
| 1237 SendRequestAndExpectQuicResponse("hello!"); | 1247 SendRequestAndExpectQuicResponse("hello!"); |
| 1238 SendRequestAndExpectQuicResponse("hello!"); | 1248 SendRequestAndExpectQuicResponse("hello!"); |
| 1239 } | 1249 } |
| 1240 | 1250 |
| 1241 // Pool to existing session with matching QuicServerId | 1251 // Pool to existing session with matching QuicServerId |
| 1242 // even if alternative service destination is different. | 1252 // even if alternative service destination is different. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 &response_header_offset)); | 1454 &response_header_offset)); |
| 1445 mock_quic_data.AddRead(ConstructServerDataPacket( | 1455 mock_quic_data.AddRead(ConstructServerDataPacket( |
| 1446 4, kClientDataStreamId2, false, true, 0, "hello from mail QUIC!")); | 1456 4, kClientDataStreamId2, false, true, 0, "hello from mail QUIC!")); |
| 1447 mock_quic_data.AddWrite( | 1457 mock_quic_data.AddWrite( |
| 1448 ConstructClientAckAndConnectionClosePacket(4, 4, 3, 1)); | 1458 ConstructClientAckAndConnectionClosePacket(4, 4, 3, 1)); |
| 1449 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1459 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1450 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1460 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1451 | 1461 |
| 1452 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1462 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1453 | 1463 |
| 1464 AddHangingNonAlternateProtocolSocketData(); |
| 1454 CreateSession(); | 1465 CreateSession(); |
| 1455 | 1466 |
| 1456 // Send two HTTP requests, responses set up alt-svc lists for the origins. | 1467 // Send two HTTP requests, responses set up alt-svc lists for the origins. |
| 1457 request_.url = GURL("https://www.example.org/"); | 1468 request_.url = GURL("https://www.example.org/"); |
| 1458 SendRequestAndExpectHttpResponse("hello world from www.example.org"); | 1469 SendRequestAndExpectHttpResponse("hello world from www.example.org"); |
| 1459 request_.url = GURL("https://mail.example.org/"); | 1470 request_.url = GURL("https://mail.example.org/"); |
| 1460 SendRequestAndExpectHttpResponse("hello world from mail.example.org"); | 1471 SendRequestAndExpectHttpResponse("hello world from mail.example.org"); |
| 1461 | 1472 |
| 1462 // Open a QUIC session to mail.example.org:443 when making request | 1473 // Open a QUIC session to mail.example.org:443 when making request |
| 1463 // to mail.example.org. | 1474 // to mail.example.org. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1475 MockRead(kQuicAlternativeServiceDifferentPortHeader), | 1486 MockRead(kQuicAlternativeServiceDifferentPortHeader), |
| 1476 MockRead("hello world"), | 1487 MockRead("hello world"), |
| 1477 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 1488 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 1478 MockRead(ASYNC, OK)}; | 1489 MockRead(ASYNC, OK)}; |
| 1479 | 1490 |
| 1480 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, | 1491 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, |
| 1481 0); | 1492 0); |
| 1482 socket_factory_.AddSocketDataProvider(&http_data); | 1493 socket_factory_.AddSocketDataProvider(&http_data); |
| 1483 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); | 1494 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); |
| 1484 | 1495 |
| 1496 AddHangingNonAlternateProtocolSocketData(); |
| 1485 CreateSession(); | 1497 CreateSession(); |
| 1486 | 1498 |
| 1487 SendRequestAndExpectHttpResponse("hello world"); | 1499 SendRequestAndExpectHttpResponse("hello world"); |
| 1488 | 1500 |
| 1489 url::SchemeHostPort http_server("https", kDefaultServerHostName, 443); | 1501 url::SchemeHostPort http_server("https", kDefaultServerHostName, 443); |
| 1490 AlternativeServiceVector alternative_service_vector = | 1502 AlternativeServiceVector alternative_service_vector = |
| 1491 http_server_properties_.GetAlternativeServices(http_server); | 1503 http_server_properties_.GetAlternativeServices(http_server); |
| 1492 ASSERT_EQ(1u, alternative_service_vector.size()); | 1504 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 1493 const AlternativeService alternative_service = alternative_service_vector[0]; | 1505 const AlternativeService alternative_service = alternative_service_vector[0]; |
| 1494 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol); | 1506 EXPECT_EQ(QUIC, alternative_service_vector[0].protocol); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1515 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 1527 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 1516 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1528 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 1517 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 1529 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 1518 false, true, 0, "hello!")); | 1530 false, true, 0, "hello!")); |
| 1519 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 1531 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 1520 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1532 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1521 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1533 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1522 | 1534 |
| 1523 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1535 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1524 | 1536 |
| 1537 AddHangingNonAlternateProtocolSocketData(); |
| 1525 CreateSession(); | 1538 CreateSession(); |
| 1526 | 1539 |
| 1527 AlternativeService alternative_service(QUIC, | 1540 AlternativeService alternative_service(QUIC, |
| 1528 HostPortPair::FromURL(request_.url)); | 1541 HostPortPair::FromURL(request_.url)); |
| 1529 http_server_properties_.MarkAlternativeServiceRecentlyBroken( | 1542 http_server_properties_.MarkAlternativeServiceRecentlyBroken( |
| 1530 alternative_service); | 1543 alternative_service); |
| 1531 EXPECT_TRUE(http_server_properties_.WasAlternativeServiceRecentlyBroken( | 1544 EXPECT_TRUE(http_server_properties_.WasAlternativeServiceRecentlyBroken( |
| 1532 alternative_service)); | 1545 alternative_service)); |
| 1533 | 1546 |
| 1534 SendRequestAndExpectHttpResponse("hello world"); | 1547 SendRequestAndExpectHttpResponse("hello world"); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 1604 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 1592 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1605 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 1593 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 1606 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 1594 false, true, 0, "hello!")); | 1607 false, true, 0, "hello!")); |
| 1595 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 1608 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 1596 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1609 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1597 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1610 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1598 | 1611 |
| 1599 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1612 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1600 | 1613 |
| 1614 // The non-alternate protocol job needs to hang in order to guarantee that |
| 1615 // the alternate-protocol job will "win". |
| 1616 AddHangingNonAlternateProtocolSocketData(); |
| 1617 |
| 1601 params_.parse_alternative_services = false; | 1618 params_.parse_alternative_services = false; |
| 1602 params_.parse_alternative_services = false; | 1619 params_.parse_alternative_services = false; |
| 1603 CreateSession(); | 1620 CreateSession(); |
| 1604 | 1621 |
| 1605 SendRequestAndExpectHttpResponse("hello world"); | 1622 SendRequestAndExpectHttpResponse("hello world"); |
| 1606 SendRequestAndExpectQuicResponse("hello!"); | 1623 SendRequestAndExpectQuicResponse("hello!"); |
| 1607 } | 1624 } |
| 1608 | 1625 |
| 1609 TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolWithProbabilityForQuic) { | 1626 TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolWithProbabilityForQuic) { |
| 1610 MockRead http_reads[] = { | 1627 MockRead http_reads[] = { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1626 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 1643 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 1627 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1644 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 1628 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 1645 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 1629 false, true, 0, "hello!")); | 1646 false, true, 0, "hello!")); |
| 1630 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 1647 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 1631 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1648 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1632 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1649 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1633 | 1650 |
| 1634 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1651 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1635 | 1652 |
| 1653 // The non-alternate protocol job needs to hang in order to guarantee that |
| 1654 // the alternate-protocol job will "win". |
| 1655 AddHangingNonAlternateProtocolSocketData(); |
| 1656 |
| 1636 params_.parse_alternative_services = false; | 1657 params_.parse_alternative_services = false; |
| 1637 params_.parse_alternative_services = false; | 1658 params_.parse_alternative_services = false; |
| 1638 CreateSession(); | 1659 CreateSession(); |
| 1639 | 1660 |
| 1640 SendRequestAndExpectHttpResponse("hello world"); | 1661 SendRequestAndExpectHttpResponse("hello world"); |
| 1641 SendRequestAndExpectQuicResponse("hello!"); | 1662 SendRequestAndExpectQuicResponse("hello!"); |
| 1642 } | 1663 } |
| 1643 | 1664 |
| 1644 TEST_P(QuicNetworkTransactionTest, AlternateProtocolDifferentPort) { | 1665 TEST_P(QuicNetworkTransactionTest, AlternateProtocolDifferentPort) { |
| 1645 MockRead http_reads[] = { | 1666 MockRead http_reads[] = { |
| 1646 MockRead("HTTP/1.1 200 OK\r\n"), | 1667 MockRead("HTTP/1.1 200 OK\r\n"), |
| 1647 MockRead(kQuicAlternateProtocolDifferentPortHeader), | 1668 MockRead(kQuicAlternateProtocolDifferentPortHeader), |
| 1648 MockRead("hello world"), | 1669 MockRead("hello world"), |
| 1649 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 1670 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 1650 MockRead(ASYNC, OK)}; | 1671 MockRead(ASYNC, OK)}; |
| 1651 | 1672 |
| 1652 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, | 1673 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, |
| 1653 0); | 1674 0); |
| 1654 socket_factory_.AddSocketDataProvider(&http_data); | 1675 socket_factory_.AddSocketDataProvider(&http_data); |
| 1655 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); | 1676 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); |
| 1656 | 1677 |
| 1678 // The non-alternate protocol job needs to hang in order to guarantee that |
| 1679 // the alternate-protocol job will "win". |
| 1680 AddHangingNonAlternateProtocolSocketData(); |
| 1681 |
| 1657 params_.parse_alternative_services = false; | 1682 params_.parse_alternative_services = false; |
| 1658 CreateSession(); | 1683 CreateSession(); |
| 1659 | 1684 |
| 1660 SendRequestAndExpectHttpResponse("hello world"); | 1685 SendRequestAndExpectHttpResponse("hello world"); |
| 1661 | 1686 |
| 1662 url::SchemeHostPort http_server("https", kDefaultServerHostName, 443); | 1687 url::SchemeHostPort http_server("https", kDefaultServerHostName, 443); |
| 1663 AlternativeServiceVector alternative_service_vector = | 1688 AlternativeServiceVector alternative_service_vector = |
| 1664 http_server_properties_.GetAlternativeServices(http_server); | 1689 http_server_properties_.GetAlternativeServices(http_server); |
| 1665 ASSERT_EQ(1u, alternative_service_vector.size()); | 1690 ASSERT_EQ(1u, alternative_service_vector.size()); |
| 1666 const AlternativeService alternative_service = alternative_service_vector[0]; | 1691 const AlternativeService alternative_service = alternative_service_vector[0]; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1688 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 1713 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 1689 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1714 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 1690 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 1715 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 1691 false, true, 0, "hello!")); | 1716 false, true, 0, "hello!")); |
| 1692 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 1717 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 1693 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1718 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1694 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1719 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1695 | 1720 |
| 1696 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1721 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1697 | 1722 |
| 1723 // The non-alternate protocol job needs to hang in order to guarantee that |
| 1724 // the alternate-protocol job will "win". |
| 1725 AddHangingNonAlternateProtocolSocketData(); |
| 1726 |
| 1698 params_.parse_alternative_services = false; | 1727 params_.parse_alternative_services = false; |
| 1699 CreateSession(); | 1728 CreateSession(); |
| 1700 | 1729 |
| 1701 AlternativeService alternative_service(QUIC, | 1730 AlternativeService alternative_service(QUIC, |
| 1702 HostPortPair::FromURL(request_.url)); | 1731 HostPortPair::FromURL(request_.url)); |
| 1703 http_server_properties_.MarkAlternativeServiceRecentlyBroken( | 1732 http_server_properties_.MarkAlternativeServiceRecentlyBroken( |
| 1704 alternative_service); | 1733 alternative_service); |
| 1705 EXPECT_TRUE(http_server_properties_.WasAlternativeServiceRecentlyBroken( | 1734 EXPECT_TRUE(http_server_properties_.WasAlternativeServiceRecentlyBroken( |
| 1706 alternative_service)); | 1735 alternative_service)); |
| 1707 | 1736 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1732 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 1761 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 1733 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1762 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 1734 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 1763 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 1735 false, true, 0, "hello!")); | 1764 false, true, 0, "hello!")); |
| 1736 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 1765 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 1737 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1766 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1738 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1767 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1739 | 1768 |
| 1740 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1769 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1741 | 1770 |
| 1771 // The non-alternate protocol job needs to hang in order to guarantee that |
| 1772 // the alternate-protocol job will "win". |
| 1742 AddHangingNonAlternateProtocolSocketData(); | 1773 AddHangingNonAlternateProtocolSocketData(); |
| 1774 |
| 1743 CreateSession(); | 1775 CreateSession(); |
| 1744 | 1776 |
| 1745 // TODO(rtenneti): Test QUIC over HTTPS, GetSSLInfo(). | 1777 // TODO(rtenneti): Test QUIC over HTTPS, GetSSLInfo(). |
| 1746 SendRequestAndExpectHttpResponse("hello world"); | 1778 SendRequestAndExpectHttpResponse("hello world"); |
| 1747 } | 1779 } |
| 1748 | 1780 |
| 1749 TEST_P(QuicNetworkTransactionTest, HungAlternateProtocol) { | 1781 TEST_P(QuicNetworkTransactionTest, HungAlternateProtocol) { |
| 1750 params_.parse_alternative_services = false; | 1782 params_.parse_alternative_services = false; |
| 1751 crypto_client_stream_factory_.set_handshake_mode( | 1783 crypto_client_stream_factory_.set_handshake_mode( |
| 1752 MockCryptoClientStream::COLD_START); | 1784 MockCryptoClientStream::COLD_START); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 1838 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 1807 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1839 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 1808 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 1840 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 1809 false, true, 0, "hello!")); | 1841 false, true, 0, "hello!")); |
| 1810 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 1842 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 1811 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1843 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
| 1812 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1844 mock_quic_data.AddRead(ASYNC, 0); // EOF |
| 1813 | 1845 |
| 1814 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1846 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1815 | 1847 |
| 1848 // The non-alternate protocol job needs to hang in order to guarantee that |
| 1849 // the alternate-protocol job will "win". |
| 1850 AddHangingNonAlternateProtocolSocketData(); |
| 1851 |
| 1816 CreateSession(); | 1852 CreateSession(); |
| 1817 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 1853 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 1818 SendRequestAndExpectQuicResponse("hello!"); | 1854 SendRequestAndExpectQuicResponse("hello!"); |
| 1819 } | 1855 } |
| 1820 | 1856 |
| 1821 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) { | 1857 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) { |
| 1822 MockQuicData mock_quic_data; | 1858 MockQuicData mock_quic_data; |
| 1823 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( | 1859 mock_quic_data.AddWrite(ConstructClientRequestHeadersPacket( |
| 1824 1, kClientDataStreamId1, true, true, | 1860 1, kClientDataStreamId1, true, true, |
| 1825 GetRequestHeaders("GET", "https", "/"))); | 1861 GetRequestHeaders("GET", "https", "/"))); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1836 // without racing an HTTP connection, we need the host resolution to happen | 1872 // without racing an HTTP connection, we need the host resolution to happen |
| 1837 // synchronously. | 1873 // synchronously. |
| 1838 host_resolver_.set_synchronous_mode(true); | 1874 host_resolver_.set_synchronous_mode(true); |
| 1839 host_resolver_.rules()->AddIPLiteralRule("mail.example.org", "192.168.0.1", | 1875 host_resolver_.rules()->AddIPLiteralRule("mail.example.org", "192.168.0.1", |
| 1840 ""); | 1876 ""); |
| 1841 HostResolver::RequestInfo info(HostPortPair("mail.example.org", 443)); | 1877 HostResolver::RequestInfo info(HostPortPair("mail.example.org", 443)); |
| 1842 AddressList address; | 1878 AddressList address; |
| 1843 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(), | 1879 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(), |
| 1844 nullptr, net_log_.bound()); | 1880 nullptr, net_log_.bound()); |
| 1845 | 1881 |
| 1882 AddHangingNonAlternateProtocolSocketData(); |
| 1846 CreateSession(); | 1883 CreateSession(); |
| 1847 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 1884 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 1848 SendRequestAndExpectQuicResponse("hello!"); | 1885 SendRequestAndExpectQuicResponse("hello!"); |
| 1849 } | 1886 } |
| 1850 | 1887 |
| 1851 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithProxy) { | 1888 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithProxy) { |
| 1852 proxy_service_ = ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"); | 1889 proxy_service_ = ProxyService::CreateFixedFromPacResult("PROXY myproxy:70"); |
| 1853 | 1890 |
| 1854 // Since we are using a proxy, the QUIC job will not succeed. | 1891 // Since we are using a proxy, the QUIC job will not succeed. |
| 1855 MockWrite http_writes[] = { | 1892 MockWrite http_writes[] = { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1889 1, kClientDataStreamId1, true, true, | 1926 1, kClientDataStreamId1, true, true, |
| 1890 GetRequestHeaders("GET", "https", "/"))); | 1927 GetRequestHeaders("GET", "https", "/"))); |
| 1891 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 1928 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 1892 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1929 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 1893 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 1930 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 1894 false, true, 0, "hello!")); | 1931 false, true, 0, "hello!")); |
| 1895 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 1932 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 1896 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more data to read | 1933 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more data to read |
| 1897 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1934 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 1898 | 1935 |
| 1936 // The non-alternate protocol job needs to hang in order to guarantee that |
| 1937 // the alternate-protocol job will "win". |
| 1938 AddHangingNonAlternateProtocolSocketData(); |
| 1939 |
| 1899 // In order for a new QUIC session to be established via alternate-protocol | 1940 // In order for a new QUIC session to be established via alternate-protocol |
| 1900 // without racing an HTTP connection, we need the host resolution to happen | 1941 // without racing an HTTP connection, we need the host resolution to happen |
| 1901 // synchronously. Of course, even though QUIC *could* perform a 0-RTT | 1942 // synchronously. Of course, even though QUIC *could* perform a 0-RTT |
| 1902 // connection to the the server, in this test we require confirmation | 1943 // connection to the the server, in this test we require confirmation |
| 1903 // before encrypting so the HTTP job will still start. | 1944 // before encrypting so the HTTP job will still start. |
| 1904 host_resolver_.set_synchronous_mode(true); | 1945 host_resolver_.set_synchronous_mode(true); |
| 1905 host_resolver_.rules()->AddIPLiteralRule("mail.example.org", "192.168.0.1", | 1946 host_resolver_.rules()->AddIPLiteralRule("mail.example.org", "192.168.0.1", |
| 1906 ""); | 1947 ""); |
| 1907 HostResolver::RequestInfo info(HostPortPair("mail.example.org", 443)); | 1948 HostResolver::RequestInfo info(HostPortPair("mail.example.org", 443)); |
| 1908 AddressList address; | 1949 AddressList address; |
| 1909 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(), | 1950 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(), |
| 1910 nullptr, net_log_.bound()); | 1951 nullptr, net_log_.bound()); |
| 1911 | 1952 |
| 1912 // The non-alternate protocol job needs to hang in order to guarantee that | |
| 1913 // the alternate-protocol job will "win". | |
| 1914 AddHangingNonAlternateProtocolSocketData(); | |
| 1915 | |
| 1916 CreateSession(); | 1953 CreateSession(); |
| 1917 session_->quic_stream_factory()->set_require_confirmation(true); | 1954 session_->quic_stream_factory()->set_require_confirmation(true); |
| 1918 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 1955 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 1919 | 1956 |
| 1920 std::unique_ptr<HttpNetworkTransaction> trans( | 1957 std::unique_ptr<HttpNetworkTransaction> trans( |
| 1921 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | 1958 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
| 1922 TestCompletionCallback callback; | 1959 TestCompletionCallback callback; |
| 1923 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); | 1960 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); |
| 1924 EXPECT_EQ(ERR_IO_PENDING, rv); | 1961 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 1925 | 1962 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 MockRead http_reads[] = { | 2141 MockRead http_reads[] = { |
| 2105 MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED), | 2142 MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED), |
| 2106 }; | 2143 }; |
| 2107 | 2144 |
| 2108 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, | 2145 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, |
| 2109 0); | 2146 0); |
| 2110 http_data.set_connect_data(MockConnect(ASYNC, ERR_SOCKET_NOT_CONNECTED)); | 2147 http_data.set_connect_data(MockConnect(ASYNC, ERR_SOCKET_NOT_CONNECTED)); |
| 2111 socket_factory_.AddSocketDataProvider(&http_data); | 2148 socket_factory_.AddSocketDataProvider(&http_data); |
| 2112 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); | 2149 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); |
| 2113 | 2150 |
| 2151 AddHangingNonAlternateProtocolSocketData(); |
| 2114 CreateSession(); | 2152 CreateSession(); |
| 2115 | 2153 |
| 2116 AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START); | 2154 AddQuicAlternateProtocolMapping(MockCryptoClientStream::COLD_START); |
| 2117 std::unique_ptr<HttpNetworkTransaction> trans( | 2155 std::unique_ptr<HttpNetworkTransaction> trans( |
| 2118 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | 2156 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
| 2119 TestCompletionCallback callback; | 2157 TestCompletionCallback callback; |
| 2120 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); | 2158 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); |
| 2121 EXPECT_EQ(ERR_IO_PENDING, rv); | 2159 EXPECT_EQ(ERR_IO_PENDING, rv); |
| 2122 EXPECT_EQ(ERR_SOCKET_NOT_CONNECTED, callback.WaitForResult()); | 2160 EXPECT_EQ(ERR_SOCKET_NOT_CONNECTED, callback.WaitForResult()); |
| 2123 ExpectQuicAlternateProtocolMapping(); | 2161 ExpectQuicAlternateProtocolMapping(); |
| 2124 } | 2162 } |
| 2125 | 2163 |
| 2126 TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) { | 2164 TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) { |
| 2127 // Alternate-protocol job | 2165 // Alternate-protocol job |
| 2128 MockRead quic_reads[] = { | 2166 MockRead quic_reads[] = { |
| 2129 MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED), | 2167 MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED), |
| 2130 }; | 2168 }; |
| 2131 StaticSocketDataProvider quic_data(quic_reads, arraysize(quic_reads), nullptr, | 2169 StaticSocketDataProvider quic_data(quic_reads, arraysize(quic_reads), nullptr, |
| 2132 0); | 2170 0); |
| 2133 socket_factory_.AddSocketDataProvider(&quic_data); | 2171 socket_factory_.AddSocketDataProvider(&quic_data); |
| 2134 | 2172 |
| 2173 AddHangingNonAlternateProtocolSocketData(); |
| 2174 |
| 2135 // Second Alternate-protocol job which will race with the TCP job. | 2175 // Second Alternate-protocol job which will race with the TCP job. |
| 2136 StaticSocketDataProvider quic_data2(quic_reads, arraysize(quic_reads), | 2176 StaticSocketDataProvider quic_data2(quic_reads, arraysize(quic_reads), |
| 2137 nullptr, 0); | 2177 nullptr, 0); |
| 2138 socket_factory_.AddSocketDataProvider(&quic_data2); | 2178 socket_factory_.AddSocketDataProvider(&quic_data2); |
| 2139 | 2179 |
| 2140 // Final job that will proceed when the QUIC job fails. | 2180 // Final job that will proceed when the QUIC job fails. |
| 2141 MockRead http_reads[] = { | 2181 MockRead http_reads[] = { |
| 2142 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello from http"), | 2182 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello from http"), |
| 2143 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 2183 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 2144 MockRead(ASYNC, OK)}; | 2184 MockRead(ASYNC, OK)}; |
| 2145 | 2185 |
| 2146 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, | 2186 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, |
| 2147 0); | 2187 0); |
| 2148 socket_factory_.AddSocketDataProvider(&http_data); | 2188 socket_factory_.AddSocketDataProvider(&http_data); |
| 2149 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); | 2189 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); |
| 2150 | 2190 |
| 2151 AddHangingNonAlternateProtocolSocketData(); | |
| 2152 CreateSession(); | 2191 CreateSession(); |
| 2153 | 2192 |
| 2154 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 2193 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 2155 | 2194 |
| 2156 SendRequestAndExpectHttpResponse("hello from http"); | 2195 SendRequestAndExpectHttpResponse("hello from http"); |
| 2157 | 2196 |
| 2158 ExpectBrokenAlternateProtocolMapping(); | 2197 ExpectBrokenAlternateProtocolMapping(); |
| 2159 | 2198 |
| 2160 EXPECT_TRUE(quic_data.AllReadDataConsumed()); | 2199 EXPECT_TRUE(quic_data.AllReadDataConsumed()); |
| 2161 EXPECT_TRUE(quic_data.AllWriteDataConsumed()); | 2200 EXPECT_TRUE(quic_data.AllWriteDataConsumed()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2173 // Main job that will proceed when the QUIC job fails. | 2212 // Main job that will proceed when the QUIC job fails. |
| 2174 MockRead http_reads[] = { | 2213 MockRead http_reads[] = { |
| 2175 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello from http"), | 2214 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello from http"), |
| 2176 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 2215 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
| 2177 MockRead(ASYNC, OK)}; | 2216 MockRead(ASYNC, OK)}; |
| 2178 | 2217 |
| 2179 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, | 2218 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, |
| 2180 0); | 2219 0); |
| 2181 socket_factory_.AddSocketDataProvider(&http_data); | 2220 socket_factory_.AddSocketDataProvider(&http_data); |
| 2182 | 2221 |
| 2222 AddHangingNonAlternateProtocolSocketData(); |
| 2183 CreateSession(); | 2223 CreateSession(); |
| 2184 | 2224 |
| 2185 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 2225 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
| 2186 | 2226 |
| 2187 SendRequestAndExpectHttpResponse("hello from http"); | 2227 SendRequestAndExpectHttpResponse("hello from http"); |
| 2188 } | 2228 } |
| 2189 | 2229 |
| 2190 TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolOnConnectFailure) { | 2230 TEST_P(QuicNetworkTransactionTest, BrokenAlternateProtocolOnConnectFailure) { |
| 2191 // Alternate-protocol job will fail before creating a QUIC session. | 2231 // Alternate-protocol job will fail before creating a QUIC session. |
| 2192 StaticSocketDataProvider quic_data(nullptr, 0, nullptr, 0); | 2232 StaticSocketDataProvider quic_data(nullptr, 0, nullptr, 0); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2259 GetRequestHeaders("GET", "https", "/"))); | 2299 GetRequestHeaders("GET", "https", "/"))); |
| 2260 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( | 2300 mock_quic_data.AddRead(ConstructServerResponseHeadersPacket( |
| 2261 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 2301 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
| 2262 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, | 2302 mock_quic_data.AddRead(ConstructServerDataPacket(2, kClientDataStreamId1, |
| 2263 false, true, 0, "hello!")); | 2303 false, true, 0, "hello!")); |
| 2264 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); | 2304 mock_quic_data.AddWrite(ConstructClientAckPacket(2, 1)); |
| 2265 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more read data. | 2305 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more read data. |
| 2266 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 2306 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
| 2267 | 2307 |
| 2268 request_.url = GURL("https://www.example.org:443"); | 2308 request_.url = GURL("https://www.example.org:443"); |
| 2309 AddHangingNonAlternateProtocolSocketData(); |
| 2269 CreateSession(); | 2310 CreateSession(); |
| 2270 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2311 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); |
| 2271 SendRequestAndExpectQuicResponse("hello!"); | 2312 SendRequestAndExpectQuicResponse("hello!"); |
| 2272 EXPECT_TRUE( | 2313 EXPECT_TRUE( |
| 2273 test_socket_performance_watcher_factory_.rtt_notification_received()); | 2314 test_socket_performance_watcher_factory_.rtt_notification_received()); |
| 2274 } | 2315 } |
| 2275 | 2316 |
| 2276 TEST_P(QuicNetworkTransactionTest, QuicUpload) { | 2317 TEST_P(QuicNetworkTransactionTest, QuicUpload) { |
| 2277 params_.origins_to_force_quic_on.insert( | 2318 params_.origins_to_force_quic_on.insert( |
| 2278 HostPortPair::FromString("mail.example.org:443")); | 2319 HostPortPair::FromString("mail.example.org:443")); |
| 2279 | 2320 |
| 2280 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 2321 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
| 2281 MockWrite writes[] = {MockWrite(SYNCHRONOUS, ERR_FAILED, 1)}; | 2322 MockWrite writes[] = {MockWrite(SYNCHRONOUS, ERR_FAILED, 1)}; |
| 2282 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 2323 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
| 2283 arraysize(writes)); | 2324 arraysize(writes)); |
| 2284 socket_factory_.AddSocketDataProvider(&socket_data); | 2325 socket_factory_.AddSocketDataProvider(&socket_data); |
| 2285 | 2326 |
| 2327 // The non-alternate protocol job needs to hang in order to guarantee that |
| 2328 // the alternate-protocol job will "win". |
| 2329 AddHangingNonAlternateProtocolSocketData(); |
| 2330 |
| 2286 params_.enable_alternative_service_with_different_host = false; | 2331 params_.enable_alternative_service_with_different_host = false; |
| 2287 CreateSession(); | 2332 CreateSession(); |
| 2288 request_.method = "POST"; | 2333 request_.method = "POST"; |
| 2289 ChunkedUploadDataStream upload_data(0); | 2334 ChunkedUploadDataStream upload_data(0); |
| 2290 upload_data.AppendData("1", 1, true); | 2335 upload_data.AppendData("1", 1, true); |
| 2291 | 2336 |
| 2292 request_.upload_data_stream = &upload_data; | 2337 request_.upload_data_stream = &upload_data; |
| 2293 | 2338 |
| 2294 std::unique_ptr<HttpNetworkTransaction> trans( | 2339 std::unique_ptr<HttpNetworkTransaction> trans( |
| 2295 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | 2340 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2712 AddHangingSocketData(); | 2757 AddHangingSocketData(); |
| 2713 | 2758 |
| 2714 SendRequestAndExpectQuicResponse(origin1_); | 2759 SendRequestAndExpectQuicResponse(origin1_); |
| 2715 SendRequestAndExpectQuicResponse(origin2_); | 2760 SendRequestAndExpectQuicResponse(origin2_); |
| 2716 | 2761 |
| 2717 EXPECT_TRUE(AllDataConsumed()); | 2762 EXPECT_TRUE(AllDataConsumed()); |
| 2718 } | 2763 } |
| 2719 | 2764 |
| 2720 } // namespace test | 2765 } // namespace test |
| 2721 } // namespace net | 2766 } // namespace net |
| OLD | NEW |