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 <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 GetRequestHeaders("GET", "https", "/"))); | 639 GetRequestHeaders("GET", "https", "/"))); |
640 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 640 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
641 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 641 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
642 mock_quic_data.AddRead( | 642 mock_quic_data.AddRead( |
643 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 643 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
644 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 644 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
645 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more data to read | 645 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more data to read |
646 | 646 |
647 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 647 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
648 | 648 |
649 // The non-alternate protocol job needs to hang in order to guarantee that | |
650 // the alternate-protocol job will "win". | |
651 AddHangingNonAlternateProtocolSocketData(); | |
652 | |
653 params_.parse_alternative_services = false; | 649 params_.parse_alternative_services = false; |
654 params_.enable_alternative_service_with_different_host = false; | 650 params_.enable_alternative_service_with_different_host = false; |
655 CreateSession(); | 651 CreateSession(); |
656 | 652 |
657 EXPECT_FALSE( | 653 EXPECT_FALSE( |
658 test_socket_performance_watcher_factory_.rtt_notification_received()); | 654 test_socket_performance_watcher_factory_.rtt_notification_received()); |
659 SendRequestAndExpectQuicResponse("hello!"); | 655 SendRequestAndExpectQuicResponse("hello!"); |
660 EXPECT_TRUE( | 656 EXPECT_TRUE( |
661 test_socket_performance_watcher_factory_.rtt_notification_received()); | 657 test_socket_performance_watcher_factory_.rtt_notification_received()); |
662 | 658 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 EXPECT_TRUE(cert->VerifyNameMatch(proxy_host, &common_name_fallback_used)); | 762 EXPECT_TRUE(cert->VerifyNameMatch(proxy_host, &common_name_fallback_used)); |
767 EXPECT_FALSE(cert->VerifyNameMatch(origin_host, &common_name_fallback_used)); | 763 EXPECT_FALSE(cert->VerifyNameMatch(origin_host, &common_name_fallback_used)); |
768 ProofVerifyDetailsChromium verify_details; | 764 ProofVerifyDetailsChromium verify_details; |
769 verify_details.cert_verify_result.verified_cert = cert; | 765 verify_details.cert_verify_result.verified_cert = cert; |
770 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); | 766 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details); |
771 ProofVerifyDetailsChromium verify_details2; | 767 ProofVerifyDetailsChromium verify_details2; |
772 verify_details2.cert_verify_result.verified_cert = cert; | 768 verify_details2.cert_verify_result.verified_cert = cert; |
773 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); | 769 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2); |
774 | 770 |
775 request_.url = GURL("http://" + origin_host); | 771 request_.url = GURL("http://" + origin_host); |
776 AddHangingNonAlternateProtocolSocketData(); | |
777 CreateSession(); | 772 CreateSession(); |
778 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); | 773 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); |
779 SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 70); | 774 SendRequestAndExpectQuicResponseFromProxyOnPort("hello!", 70); |
780 } | 775 } |
781 | 776 |
782 TEST_P(QuicNetworkTransactionTest, AlternativeServicesDifferentHost) { | 777 TEST_P(QuicNetworkTransactionTest, AlternativeServicesDifferentHost) { |
783 params_.enable_alternative_service_with_different_host = true; | 778 params_.enable_alternative_service_with_different_host = true; |
784 HostPortPair origin("www.example.org", 443); | 779 HostPortPair origin("www.example.org", 443); |
785 HostPortPair alternative("mail.example.org", 443); | 780 HostPortPair alternative("mail.example.org", 443); |
786 | 781 |
(...skipping 21 matching lines...) Expand all Loading... |
808 mock_quic_data.AddRead( | 803 mock_quic_data.AddRead( |
809 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 804 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
810 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 805 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
811 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 806 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
812 mock_quic_data.AddRead(ASYNC, 0); | 807 mock_quic_data.AddRead(ASYNC, 0); |
813 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 808 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
814 | 809 |
815 request_.url = GURL("https://" + origin.host()); | 810 request_.url = GURL("https://" + origin.host()); |
816 AddQuicRemoteAlternativeServiceMapping( | 811 AddQuicRemoteAlternativeServiceMapping( |
817 MockCryptoClientStream::CONFIRM_HANDSHAKE, alternative); | 812 MockCryptoClientStream::CONFIRM_HANDSHAKE, alternative); |
818 AddHangingNonAlternateProtocolSocketData(); | |
819 CreateSession(); | 813 CreateSession(); |
820 | 814 |
821 SendRequestAndExpectQuicResponse("hello!"); | 815 SendRequestAndExpectQuicResponse("hello!"); |
822 } | 816 } |
823 | 817 |
824 TEST_P(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) { | 818 TEST_P(QuicNetworkTransactionTest, ForceQuicWithErrorConnecting) { |
825 params_.origins_to_force_quic_on.insert( | 819 params_.origins_to_force_quic_on.insert( |
826 HostPortPair::FromString("mail.example.org:443")); | 820 HostPortPair::FromString("mail.example.org:443")); |
827 | 821 |
828 MockQuicData mock_quic_data1; | 822 MockQuicData mock_quic_data1; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 888 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
895 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 889 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
896 mock_quic_data.AddRead( | 890 mock_quic_data.AddRead( |
897 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 891 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
898 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 892 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
899 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 893 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
900 mock_quic_data.AddRead(ASYNC, 0); // EOF | 894 mock_quic_data.AddRead(ASYNC, 0); // EOF |
901 | 895 |
902 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 896 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
903 | 897 |
904 AddHangingNonAlternateProtocolSocketData(); | |
905 CreateSession(); | 898 CreateSession(); |
906 | 899 |
907 SendRequestAndExpectHttpResponse("hello world"); | 900 SendRequestAndExpectHttpResponse("hello world"); |
908 SendRequestAndExpectQuicResponse("hello!"); | 901 SendRequestAndExpectQuicResponse("hello!"); |
909 } | 902 } |
910 | 903 |
911 TEST_P(QuicNetworkTransactionTest, | 904 TEST_P(QuicNetworkTransactionTest, |
912 UseAlternativeServiceWithProbabilityForQuic) { | 905 UseAlternativeServiceWithProbabilityForQuic) { |
913 MockRead http_reads[] = { | 906 MockRead http_reads[] = { |
914 MockRead("HTTP/1.1 200 OK\r\n"), | 907 MockRead("HTTP/1.1 200 OK\r\n"), |
(...skipping 14 matching lines...) Expand all Loading... |
929 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 922 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
930 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 923 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
931 mock_quic_data.AddRead( | 924 mock_quic_data.AddRead( |
932 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 925 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
933 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 926 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
934 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 927 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
935 mock_quic_data.AddRead(ASYNC, 0); // EOF | 928 mock_quic_data.AddRead(ASYNC, 0); // EOF |
936 | 929 |
937 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 930 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
938 | 931 |
939 AddHangingNonAlternateProtocolSocketData(); | |
940 CreateSession(); | 932 CreateSession(); |
941 | 933 |
942 SendRequestAndExpectHttpResponse("hello world"); | 934 SendRequestAndExpectHttpResponse("hello world"); |
943 SendRequestAndExpectQuicResponse("hello!"); | 935 SendRequestAndExpectQuicResponse("hello!"); |
944 } | 936 } |
945 | 937 |
946 TEST_P(QuicNetworkTransactionTest, SetAlternativeServiceWithScheme) { | 938 TEST_P(QuicNetworkTransactionTest, SetAlternativeServiceWithScheme) { |
947 MockRead http_reads[] = { | 939 MockRead http_reads[] = { |
948 MockRead("HTTP/1.1 200 OK\r\n"), | 940 MockRead("HTTP/1.1 200 OK\r\n"), |
949 MockRead("Alt-Svc: quic=\"foo.example.org:443\", quic=\":444\"\r\n\r\n"), | 941 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... |
1030 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1022 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1031 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1023 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
1032 mock_quic_data.AddRead( | 1024 mock_quic_data.AddRead( |
1033 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1025 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
1034 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1026 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
1035 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1027 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1036 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1028 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1037 | 1029 |
1038 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1030 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1039 | 1031 |
1040 AddHangingNonAlternateProtocolSocketData(); | |
1041 CreateSession(); | 1032 CreateSession(); |
1042 | 1033 |
1043 SendRequestAndExpectHttpResponse("hello world"); | 1034 SendRequestAndExpectHttpResponse("hello world"); |
1044 SendRequestAndExpectQuicResponse("hello!"); | 1035 SendRequestAndExpectQuicResponse("hello!"); |
1045 } | 1036 } |
1046 | 1037 |
1047 TEST_P(QuicNetworkTransactionTest, GoAwayWithConnectionMigrationOnPortsOnly) { | 1038 TEST_P(QuicNetworkTransactionTest, GoAwayWithConnectionMigrationOnPortsOnly) { |
1048 MockQuicData mock_quic_data; | 1039 MockQuicData mock_quic_data; |
1049 mock_quic_data.AddWrite( | 1040 mock_quic_data.AddWrite( |
1050 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, | 1041 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 3, kClientDataStreamId2, false, false, GetResponseHeaders("200 OK"), | 1166 3, kClientDataStreamId2, false, false, GetResponseHeaders("200 OK"), |
1176 &response_header_offset)); | 1167 &response_header_offset)); |
1177 mock_quic_data.AddRead( | 1168 mock_quic_data.AddRead( |
1178 ConstructDataPacket(4, kClientDataStreamId2, false, true, 0, "hello!")); | 1169 ConstructDataPacket(4, kClientDataStreamId2, false, true, 0, "hello!")); |
1179 mock_quic_data.AddWrite(ConstructAckAndConnectionClosePacket(4, 4, 3, 1)); | 1170 mock_quic_data.AddWrite(ConstructAckAndConnectionClosePacket(4, 4, 3, 1)); |
1180 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1171 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1181 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1172 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1182 | 1173 |
1183 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1174 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1184 | 1175 |
1185 AddHangingNonAlternateProtocolSocketData(); | |
1186 CreateSession(); | 1176 CreateSession(); |
1187 | 1177 |
1188 SendRequestAndExpectHttpResponse("hello world"); | 1178 SendRequestAndExpectHttpResponse("hello world"); |
1189 | 1179 |
1190 SendRequestAndExpectQuicResponseOnPort("hello!", 443); | 1180 SendRequestAndExpectQuicResponseOnPort("hello!", 443); |
1191 SendRequestAndExpectQuicResponseOnPort("hello!", 443); | 1181 SendRequestAndExpectQuicResponseOnPort("hello!", 443); |
1192 } | 1182 } |
1193 | 1183 |
1194 // When multiple alternative services that has existing QUIC session. | 1184 // When multiple alternative services that has existing QUIC session. |
1195 // HttpStreamFactoryImpl::RequestStreamInternal() should select the first | 1185 // HttpStreamFactoryImpl::RequestStreamInternal() should select the first |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1250 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1261 3, kClientDataStreamId2, false, false, GetResponseHeaders("200 OK"), | 1251 3, kClientDataStreamId2, false, false, GetResponseHeaders("200 OK"), |
1262 &response_header_offset)); | 1252 &response_header_offset)); |
1263 mock_quic_data.AddRead(ConstructDataPacket(4, kClientDataStreamId2, false, | 1253 mock_quic_data.AddRead(ConstructDataPacket(4, kClientDataStreamId2, false, |
1264 true, 0, "hello from foo!")); | 1254 true, 0, "hello from foo!")); |
1265 mock_quic_data.AddWrite(ConstructAckAndConnectionClosePacket(4, 4, 3, 1)); | 1255 mock_quic_data.AddWrite(ConstructAckAndConnectionClosePacket(4, 4, 3, 1)); |
1266 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1256 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1267 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1257 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1268 | 1258 |
1269 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1259 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1270 AddHangingNonAlternateProtocolSocketData(); | |
1271 | |
1272 mock_quic_data2.AddSocketDataToFactory(&socket_factory_); | 1260 mock_quic_data2.AddSocketDataToFactory(&socket_factory_); |
1273 | 1261 |
1274 AddHangingNonAlternateProtocolSocketData(); | |
1275 | |
1276 CreateSession(); | 1262 CreateSession(); |
1277 | 1263 |
1278 SendRequestAndExpectHttpResponse("hello world"); | 1264 SendRequestAndExpectHttpResponse("hello world"); |
1279 SendRequestAndExpectQuicResponseOnPort("hello from foo!", 443); | 1265 SendRequestAndExpectQuicResponseOnPort("hello from foo!", 443); |
1280 SendRequestAndExpectQuicResponseOnPort("hello from bar!", 444); | 1266 SendRequestAndExpectQuicResponseOnPort("hello from bar!", 444); |
1281 SendRequestAndExpectQuicResponseOnPort("hello from foo!", 443); | 1267 SendRequestAndExpectQuicResponseOnPort("hello from foo!", 443); |
1282 } | 1268 } |
1283 | 1269 |
1284 // Multiple origins have listed the same alternative services. When there's a | 1270 // Multiple origins have listed the same alternative services. When there's a |
1285 // existing QUIC session opened by a request to other origin, | 1271 // existing QUIC session opened by a request to other origin, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1341 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1327 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1342 3, kClientDataStreamId2, false, false, GetResponseHeaders("200 OK"), | 1328 3, kClientDataStreamId2, false, false, GetResponseHeaders("200 OK"), |
1343 &response_header_offset)); | 1329 &response_header_offset)); |
1344 mock_quic_data.AddRead(ConstructDataPacket(4, kClientDataStreamId2, false, | 1330 mock_quic_data.AddRead(ConstructDataPacket(4, kClientDataStreamId2, false, |
1345 true, 0, "hello from mail QUIC!")); | 1331 true, 0, "hello from mail QUIC!")); |
1346 mock_quic_data.AddWrite(ConstructAckAndConnectionClosePacket(4, 4, 3, 1)); | 1332 mock_quic_data.AddWrite(ConstructAckAndConnectionClosePacket(4, 4, 3, 1)); |
1347 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1333 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1348 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1334 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1349 | 1335 |
1350 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1336 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1351 AddHangingNonAlternateProtocolSocketData(); | |
1352 | 1337 |
1353 CreateSession(); | 1338 CreateSession(); |
1354 | 1339 |
1355 // Send two HTTP requests, responses set up alt-svc lists for the origins. | 1340 // Send two HTTP requests, responses set up alt-svc lists for the origins. |
1356 request_.url = GURL("https://www.example.org/"); | 1341 request_.url = GURL("https://www.example.org/"); |
1357 SendRequestAndExpectHttpResponse("hello world from www.example.org"); | 1342 SendRequestAndExpectHttpResponse("hello world from www.example.org"); |
1358 request_.url = GURL("https://mail.example.org/"); | 1343 request_.url = GURL("https://mail.example.org/"); |
1359 SendRequestAndExpectHttpResponse("hello world from mail.example.org"); | 1344 SendRequestAndExpectHttpResponse("hello world from mail.example.org"); |
1360 | 1345 |
1361 // Open a QUIC session to mail.example.org:443 when making request | 1346 // Open a QUIC session to mail.example.org:443 when making request |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 mock_quic_data2.AddRead( | 1419 mock_quic_data2.AddRead( |
1435 ConstructResponseHeadersPacket(1, kClientDataStreamId1, false, false, | 1420 ConstructResponseHeadersPacket(1, kClientDataStreamId1, false, false, |
1436 GetResponseHeaders("200 OK"), &maker)); | 1421 GetResponseHeaders("200 OK"), &maker)); |
1437 mock_quic_data2.AddRead(ConstructDataPacket( | 1422 mock_quic_data2.AddRead(ConstructDataPacket( |
1438 2, kClientDataStreamId1, false, true, 0, "hello from docs QUIC!")); | 1423 2, kClientDataStreamId1, false, true, 0, "hello from docs QUIC!")); |
1439 mock_quic_data2.AddWrite(ConstructAckPacket(2, 1, &maker)); | 1424 mock_quic_data2.AddWrite(ConstructAckPacket(2, 1, &maker)); |
1440 mock_quic_data2.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1425 mock_quic_data2.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1441 mock_quic_data2.AddRead(ASYNC, 0); // EOF | 1426 mock_quic_data2.AddRead(ASYNC, 0); // EOF |
1442 | 1427 |
1443 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1428 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1444 AddHangingNonAlternateProtocolSocketData(); | |
1445 | |
1446 mock_quic_data2.AddSocketDataToFactory(&socket_factory_); | 1429 mock_quic_data2.AddSocketDataToFactory(&socket_factory_); |
1447 AddHangingNonAlternateProtocolSocketData(); | |
1448 | 1430 |
1449 CreateSession(); | 1431 CreateSession(); |
1450 | 1432 |
1451 // Send HTTP requests, responses set up the alt-svc lists for the origins. | 1433 // Send HTTP requests, responses set up the alt-svc lists for the origins. |
1452 SendRequestAndExpectHttpResponse("hello world from mail.example.org"); | 1434 SendRequestAndExpectHttpResponse("hello world from mail.example.org"); |
1453 request_.url = GURL("https://mail.example.com/"); | 1435 request_.url = GURL("https://mail.example.com/"); |
1454 SendRequestAndExpectHttpResponse("hello world from mail.example.com"); | 1436 SendRequestAndExpectHttpResponse("hello world from mail.example.com"); |
1455 | 1437 |
1456 // Open a QUIC session to mail.example.org:443 when making request | 1438 // Open a QUIC session to mail.example.org:443 when making request |
1457 // to mail.example.org. | 1439 // to mail.example.org. |
(...skipping 25 matching lines...) Expand all Loading... |
1483 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1465 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1484 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1466 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
1485 mock_quic_data.AddRead( | 1467 mock_quic_data.AddRead( |
1486 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1468 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
1487 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1469 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
1488 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1470 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1489 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1471 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1490 | 1472 |
1491 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1473 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1492 | 1474 |
1493 AddHangingNonAlternateProtocolSocketData(); | |
1494 CreateSession(); | 1475 CreateSession(); |
1495 | 1476 |
1496 SendRequestAndExpectHttpResponse("hello world"); | 1477 SendRequestAndExpectHttpResponse("hello world"); |
1497 SendRequestAndExpectQuicResponseOnPort("hello!", 137); | 1478 SendRequestAndExpectQuicResponseOnPort("hello!", 137); |
1498 } | 1479 } |
1499 | 1480 |
1500 TEST_P(QuicNetworkTransactionTest, ConfirmAlternativeService) { | 1481 TEST_P(QuicNetworkTransactionTest, ConfirmAlternativeService) { |
1501 MockRead http_reads[] = { | 1482 MockRead http_reads[] = { |
1502 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(kQuicAlternativeServiceHeader), | 1483 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(kQuicAlternativeServiceHeader), |
1503 MockRead("hello world"), | 1484 MockRead("hello world"), |
(...skipping 12 matching lines...) Expand all Loading... |
1516 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1497 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1517 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1498 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
1518 mock_quic_data.AddRead( | 1499 mock_quic_data.AddRead( |
1519 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1500 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
1520 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1501 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
1521 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1502 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1522 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1503 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1523 | 1504 |
1524 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1505 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1525 | 1506 |
1526 AddHangingNonAlternateProtocolSocketData(); | |
1527 CreateSession(); | 1507 CreateSession(); |
1528 | 1508 |
1529 AlternativeService alternative_service(QUIC, | 1509 AlternativeService alternative_service(QUIC, |
1530 HostPortPair::FromURL(request_.url)); | 1510 HostPortPair::FromURL(request_.url)); |
1531 http_server_properties_.MarkAlternativeServiceRecentlyBroken( | 1511 http_server_properties_.MarkAlternativeServiceRecentlyBroken( |
1532 alternative_service); | 1512 alternative_service); |
1533 EXPECT_TRUE(http_server_properties_.WasAlternativeServiceRecentlyBroken( | 1513 EXPECT_TRUE(http_server_properties_.WasAlternativeServiceRecentlyBroken( |
1534 alternative_service)); | 1514 alternative_service)); |
1535 | 1515 |
1536 SendRequestAndExpectHttpResponse("hello world"); | 1516 SendRequestAndExpectHttpResponse("hello world"); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1593 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1573 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1594 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1574 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
1595 mock_quic_data.AddRead( | 1575 mock_quic_data.AddRead( |
1596 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1576 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
1597 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1577 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
1598 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1578 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1599 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1579 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1600 | 1580 |
1601 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1581 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1602 | 1582 |
1603 // The non-alternate protocol job needs to hang in order to guarantee that | |
1604 // the alternate-protocol job will "win". | |
1605 AddHangingNonAlternateProtocolSocketData(); | |
1606 | |
1607 params_.parse_alternative_services = false; | 1583 params_.parse_alternative_services = false; |
1608 params_.parse_alternative_services = false; | 1584 params_.parse_alternative_services = false; |
1609 CreateSession(); | 1585 CreateSession(); |
1610 | 1586 |
1611 SendRequestAndExpectHttpResponse("hello world"); | 1587 SendRequestAndExpectHttpResponse("hello world"); |
1612 SendRequestAndExpectQuicResponse("hello!"); | 1588 SendRequestAndExpectQuicResponse("hello!"); |
1613 } | 1589 } |
1614 | 1590 |
1615 TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolWithProbabilityForQuic) { | 1591 TEST_P(QuicNetworkTransactionTest, UseAlternateProtocolWithProbabilityForQuic) { |
1616 MockRead http_reads[] = { | 1592 MockRead http_reads[] = { |
(...skipping 15 matching lines...) Expand all Loading... |
1632 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1608 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1633 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1609 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
1634 mock_quic_data.AddRead( | 1610 mock_quic_data.AddRead( |
1635 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1611 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
1636 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1612 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
1637 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1613 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1638 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1614 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1639 | 1615 |
1640 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1616 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1641 | 1617 |
1642 // The non-alternate protocol job needs to hang in order to guarantee that | |
1643 // the alternate-protocol job will "win". | |
1644 AddHangingNonAlternateProtocolSocketData(); | |
1645 | |
1646 params_.parse_alternative_services = false; | 1618 params_.parse_alternative_services = false; |
1647 params_.parse_alternative_services = false; | 1619 params_.parse_alternative_services = false; |
1648 CreateSession(); | 1620 CreateSession(); |
1649 | 1621 |
1650 SendRequestAndExpectHttpResponse("hello world"); | 1622 SendRequestAndExpectHttpResponse("hello world"); |
1651 SendRequestAndExpectQuicResponse("hello!"); | 1623 SendRequestAndExpectQuicResponse("hello!"); |
1652 } | 1624 } |
1653 | 1625 |
1654 TEST_P(QuicNetworkTransactionTest, AlternateProtocolDifferentPort) { | 1626 TEST_P(QuicNetworkTransactionTest, AlternateProtocolDifferentPort) { |
1655 MockRead http_reads[] = { | 1627 MockRead http_reads[] = { |
(...skipping 15 matching lines...) Expand all Loading... |
1671 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1643 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1672 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1644 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
1673 mock_quic_data.AddRead( | 1645 mock_quic_data.AddRead( |
1674 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1646 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
1675 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1647 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
1676 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 |
1677 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1649 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1678 | 1650 |
1679 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1651 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1680 | 1652 |
1681 // The non-alternate protocol job needs to hang in order to guarantee that | |
1682 // the alternate-protocol job will "win". | |
1683 AddHangingNonAlternateProtocolSocketData(); | |
1684 | |
1685 params_.parse_alternative_services = false; | 1653 params_.parse_alternative_services = false; |
1686 CreateSession(); | 1654 CreateSession(); |
1687 | 1655 |
1688 SendRequestAndExpectHttpResponse("hello world"); | 1656 SendRequestAndExpectHttpResponse("hello world"); |
1689 SendRequestAndExpectQuicResponseOnPort("hello!", 137); | 1657 SendRequestAndExpectQuicResponseOnPort("hello!", 137); |
1690 } | 1658 } |
1691 | 1659 |
1692 TEST_P(QuicNetworkTransactionTest, ConfirmAlternateProtocol) { | 1660 TEST_P(QuicNetworkTransactionTest, ConfirmAlternateProtocol) { |
1693 MockRead http_reads[] = { | 1661 MockRead http_reads[] = { |
1694 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(kQuicAlternateProtocolHeader), | 1662 MockRead("HTTP/1.1 200 OK\r\n"), MockRead(kQuicAlternateProtocolHeader), |
(...skipping 13 matching lines...) Expand all Loading... |
1708 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1676 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1709 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1677 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
1710 mock_quic_data.AddRead( | 1678 mock_quic_data.AddRead( |
1711 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1679 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
1712 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1680 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
1713 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1681 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1714 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1682 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1715 | 1683 |
1716 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1684 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1717 | 1685 |
1718 // The non-alternate protocol job needs to hang in order to guarantee that | |
1719 // the alternate-protocol job will "win". | |
1720 AddHangingNonAlternateProtocolSocketData(); | |
1721 | |
1722 params_.parse_alternative_services = false; | 1686 params_.parse_alternative_services = false; |
1723 CreateSession(); | 1687 CreateSession(); |
1724 | 1688 |
1725 AlternativeService alternative_service(QUIC, | 1689 AlternativeService alternative_service(QUIC, |
1726 HostPortPair::FromURL(request_.url)); | 1690 HostPortPair::FromURL(request_.url)); |
1727 http_server_properties_.MarkAlternativeServiceRecentlyBroken( | 1691 http_server_properties_.MarkAlternativeServiceRecentlyBroken( |
1728 alternative_service); | 1692 alternative_service); |
1729 EXPECT_TRUE(http_server_properties_.WasAlternativeServiceRecentlyBroken( | 1693 EXPECT_TRUE(http_server_properties_.WasAlternativeServiceRecentlyBroken( |
1730 alternative_service)); | 1694 alternative_service)); |
1731 | 1695 |
(...skipping 25 matching lines...) Expand all Loading... |
1757 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1721 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1758 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1722 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
1759 mock_quic_data.AddRead( | 1723 mock_quic_data.AddRead( |
1760 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1724 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
1761 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1725 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
1762 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1726 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1763 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1727 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1764 | 1728 |
1765 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1729 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1766 | 1730 |
1767 // The non-alternate protocol job needs to hang in order to guarantee that | |
1768 // the alternate-protocol job will "win". | |
1769 AddHangingNonAlternateProtocolSocketData(); | 1731 AddHangingNonAlternateProtocolSocketData(); |
1770 | |
1771 CreateSession(); | 1732 CreateSession(); |
1772 | 1733 |
1773 // TODO(rtenneti): Test QUIC over HTTPS, GetSSLInfo(). | 1734 // TODO(rtenneti): Test QUIC over HTTPS, GetSSLInfo(). |
1774 SendRequestAndExpectHttpResponse("hello world"); | 1735 SendRequestAndExpectHttpResponse("hello world"); |
1775 } | 1736 } |
1776 | 1737 |
1777 class QuicAltSvcCertificateVerificationTest | 1738 class QuicAltSvcCertificateVerificationTest |
1778 : public QuicNetworkTransactionTest { | 1739 : public QuicNetworkTransactionTest { |
1779 public: | 1740 public: |
1780 void Run(bool valid) { | 1741 void Run(bool valid) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1878 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
1918 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1879 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
1919 mock_quic_data.AddRead( | 1880 mock_quic_data.AddRead( |
1920 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1881 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
1921 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1882 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
1922 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read | 1883 mock_quic_data.AddRead(ASYNC, ERR_IO_PENDING); // No more data to read |
1923 mock_quic_data.AddRead(ASYNC, 0); // EOF | 1884 mock_quic_data.AddRead(ASYNC, 0); // EOF |
1924 | 1885 |
1925 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1886 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
1926 | 1887 |
1927 // The non-alternate protocol job needs to hang in order to guarantee that | |
1928 // the alternate-protocol job will "win". | |
1929 AddHangingNonAlternateProtocolSocketData(); | |
1930 | |
1931 CreateSession(); | 1888 CreateSession(); |
1932 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 1889 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
1933 SendRequestAndExpectQuicResponse("hello!"); | 1890 SendRequestAndExpectQuicResponse("hello!"); |
1934 } | 1891 } |
1935 | 1892 |
1936 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) { | 1893 TEST_P(QuicNetworkTransactionTest, ZeroRTTWithNoHttpRace) { |
1937 MockQuicData mock_quic_data; | 1894 MockQuicData mock_quic_data; |
1938 mock_quic_data.AddWrite( | 1895 mock_quic_data.AddWrite( |
1939 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, | 1896 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, |
1940 GetRequestHeaders("GET", "https", "/"))); | 1897 GetRequestHeaders("GET", "https", "/"))); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, | 1961 ConstructRequestHeadersPacket(1, kClientDataStreamId1, true, true, |
2005 GetRequestHeaders("GET", "https", "/"))); | 1962 GetRequestHeaders("GET", "https", "/"))); |
2006 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 1963 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
2007 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 1964 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
2008 mock_quic_data.AddRead( | 1965 mock_quic_data.AddRead( |
2009 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 1966 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
2010 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 1967 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
2011 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more data to read | 1968 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more data to read |
2012 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 1969 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
2013 | 1970 |
2014 // The non-alternate protocol job needs to hang in order to guarantee that | |
2015 // the alternate-protocol job will "win". | |
2016 AddHangingNonAlternateProtocolSocketData(); | |
2017 | |
2018 // In order for a new QUIC session to be established via alternate-protocol | 1971 // In order for a new QUIC session to be established via alternate-protocol |
2019 // without racing an HTTP connection, we need the host resolution to happen | 1972 // without racing an HTTP connection, we need the host resolution to happen |
2020 // synchronously. Of course, even though QUIC *could* perform a 0-RTT | 1973 // synchronously. Of course, even though QUIC *could* perform a 0-RTT |
2021 // connection to the the server, in this test we require confirmation | 1974 // connection to the the server, in this test we require confirmation |
2022 // before encrypting so the HTTP job will still start. | 1975 // before encrypting so the HTTP job will still start. |
2023 host_resolver_.set_synchronous_mode(true); | 1976 host_resolver_.set_synchronous_mode(true); |
2024 host_resolver_.rules()->AddIPLiteralRule("mail.example.org", "192.168.0.1", | 1977 host_resolver_.rules()->AddIPLiteralRule("mail.example.org", "192.168.0.1", |
2025 ""); | 1978 ""); |
2026 HostResolver::RequestInfo info(HostPortPair("mail.example.org", 443)); | 1979 HostResolver::RequestInfo info(HostPortPair("mail.example.org", 443)); |
2027 AddressList address; | 1980 AddressList address; |
2028 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(), | 1981 host_resolver_.Resolve(info, DEFAULT_PRIORITY, &address, CompletionCallback(), |
2029 nullptr, net_log_.bound()); | 1982 nullptr, net_log_.bound()); |
2030 | 1983 |
| 1984 // The non-alternate protocol job needs to hang in order to guarantee that |
| 1985 // the alternate-protocol job will "win". |
| 1986 AddHangingNonAlternateProtocolSocketData(); |
| 1987 |
2031 CreateSession(); | 1988 CreateSession(); |
2032 session_->quic_stream_factory()->set_require_confirmation(true); | 1989 session_->quic_stream_factory()->set_require_confirmation(true); |
2033 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 1990 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
2034 | 1991 |
2035 std::unique_ptr<HttpNetworkTransaction> trans( | 1992 std::unique_ptr<HttpNetworkTransaction> trans( |
2036 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | 1993 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
2037 TestCompletionCallback callback; | 1994 TestCompletionCallback callback; |
2038 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); | 1995 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); |
2039 EXPECT_EQ(ERR_IO_PENDING, rv); | 1996 EXPECT_EQ(ERR_IO_PENDING, rv); |
2040 | 1997 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 | 2196 |
2240 TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) { | 2197 TEST_P(QuicNetworkTransactionTest, FailedZeroRttBrokenAlternateProtocol) { |
2241 // Alternate-protocol job | 2198 // Alternate-protocol job |
2242 MockRead quic_reads[] = { | 2199 MockRead quic_reads[] = { |
2243 MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED), | 2200 MockRead(ASYNC, ERR_SOCKET_NOT_CONNECTED), |
2244 }; | 2201 }; |
2245 StaticSocketDataProvider quic_data(quic_reads, arraysize(quic_reads), nullptr, | 2202 StaticSocketDataProvider quic_data(quic_reads, arraysize(quic_reads), nullptr, |
2246 0); | 2203 0); |
2247 socket_factory_.AddSocketDataProvider(&quic_data); | 2204 socket_factory_.AddSocketDataProvider(&quic_data); |
2248 | 2205 |
2249 AddHangingNonAlternateProtocolSocketData(); | |
2250 | |
2251 // Second Alternate-protocol job which will race with the TCP job. | 2206 // Second Alternate-protocol job which will race with the TCP job. |
2252 StaticSocketDataProvider quic_data2(quic_reads, arraysize(quic_reads), | 2207 StaticSocketDataProvider quic_data2(quic_reads, arraysize(quic_reads), |
2253 nullptr, 0); | 2208 nullptr, 0); |
2254 socket_factory_.AddSocketDataProvider(&quic_data2); | 2209 socket_factory_.AddSocketDataProvider(&quic_data2); |
2255 | 2210 |
2256 // Final job that will proceed when the QUIC job fails. | 2211 // Final job that will proceed when the QUIC job fails. |
2257 MockRead http_reads[] = { | 2212 MockRead http_reads[] = { |
2258 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello from http"), | 2213 MockRead("HTTP/1.1 200 OK\r\n\r\n"), MockRead("hello from http"), |
2259 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), | 2214 MockRead(SYNCHRONOUS, ERR_TEST_PEER_CLOSE_AFTER_NEXT_MOCK_READ), |
2260 MockRead(ASYNC, OK)}; | 2215 MockRead(ASYNC, OK)}; |
2261 | 2216 |
2262 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, | 2217 StaticSocketDataProvider http_data(http_reads, arraysize(http_reads), nullptr, |
2263 0); | 2218 0); |
2264 socket_factory_.AddSocketDataProvider(&http_data); | 2219 socket_factory_.AddSocketDataProvider(&http_data); |
2265 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); | 2220 socket_factory_.AddSSLSocketDataProvider(&ssl_data_); |
2266 | 2221 |
| 2222 AddHangingNonAlternateProtocolSocketData(); |
2267 CreateSession(); | 2223 CreateSession(); |
2268 | 2224 |
2269 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); | 2225 AddQuicAlternateProtocolMapping(MockCryptoClientStream::ZERO_RTT); |
2270 | 2226 |
2271 SendRequestAndExpectHttpResponse("hello from http"); | 2227 SendRequestAndExpectHttpResponse("hello from http"); |
2272 | 2228 |
2273 ExpectBrokenAlternateProtocolMapping(); | 2229 ExpectBrokenAlternateProtocolMapping(); |
2274 | 2230 |
2275 EXPECT_TRUE(quic_data.AllReadDataConsumed()); | 2231 EXPECT_TRUE(quic_data.AllReadDataConsumed()); |
2276 EXPECT_TRUE(quic_data.AllWriteDataConsumed()); | 2232 EXPECT_TRUE(quic_data.AllWriteDataConsumed()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2374 GetRequestHeaders("GET", "https", "/"))); | 2330 GetRequestHeaders("GET", "https", "/"))); |
2375 mock_quic_data.AddRead(ConstructResponseHeadersPacket( | 2331 mock_quic_data.AddRead(ConstructResponseHeadersPacket( |
2376 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); | 2332 1, kClientDataStreamId1, false, false, GetResponseHeaders("200 OK"))); |
2377 mock_quic_data.AddRead( | 2333 mock_quic_data.AddRead( |
2378 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); | 2334 ConstructDataPacket(2, kClientDataStreamId1, false, true, 0, "hello!")); |
2379 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); | 2335 mock_quic_data.AddWrite(ConstructAckPacket(2, 1)); |
2380 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more read data. | 2336 mock_quic_data.AddRead(SYNCHRONOUS, ERR_IO_PENDING); // No more read data. |
2381 mock_quic_data.AddSocketDataToFactory(&socket_factory_); | 2337 mock_quic_data.AddSocketDataToFactory(&socket_factory_); |
2382 | 2338 |
2383 request_.url = GURL("https://www.example.org:443"); | 2339 request_.url = GURL("https://www.example.org:443"); |
2384 AddHangingNonAlternateProtocolSocketData(); | |
2385 CreateSession(); | 2340 CreateSession(); |
2386 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); | 2341 AddQuicAlternateProtocolMapping(MockCryptoClientStream::CONFIRM_HANDSHAKE); |
2387 SendRequestAndExpectQuicResponse("hello!"); | 2342 SendRequestAndExpectQuicResponse("hello!"); |
2388 EXPECT_TRUE( | 2343 EXPECT_TRUE( |
2389 test_socket_performance_watcher_factory_.rtt_notification_received()); | 2344 test_socket_performance_watcher_factory_.rtt_notification_received()); |
2390 } | 2345 } |
2391 | 2346 |
2392 TEST_P(QuicNetworkTransactionTest, QuicUpload) { | 2347 TEST_P(QuicNetworkTransactionTest, QuicUpload) { |
2393 params_.origins_to_force_quic_on.insert( | 2348 params_.origins_to_force_quic_on.insert( |
2394 HostPortPair::FromString("mail.example.org:443")); | 2349 HostPortPair::FromString("mail.example.org:443")); |
2395 | 2350 |
2396 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; | 2351 MockRead reads[] = {MockRead(SYNCHRONOUS, ERR_IO_PENDING, 0)}; |
2397 MockWrite writes[] = {MockWrite(SYNCHRONOUS, ERR_FAILED, 1)}; | 2352 MockWrite writes[] = {MockWrite(SYNCHRONOUS, ERR_FAILED, 1)}; |
2398 SequencedSocketData socket_data(reads, arraysize(reads), writes, | 2353 SequencedSocketData socket_data(reads, arraysize(reads), writes, |
2399 arraysize(writes)); | 2354 arraysize(writes)); |
2400 socket_factory_.AddSocketDataProvider(&socket_data); | 2355 socket_factory_.AddSocketDataProvider(&socket_data); |
2401 | 2356 |
2402 // The non-alternate protocol job needs to hang in order to guarantee that | |
2403 // the alternate-protocol job will "win". | |
2404 AddHangingNonAlternateProtocolSocketData(); | |
2405 | |
2406 params_.parse_alternative_services = false; | 2357 params_.parse_alternative_services = false; |
2407 params_.enable_alternative_service_with_different_host = false; | 2358 params_.enable_alternative_service_with_different_host = false; |
2408 CreateSession(); | 2359 CreateSession(); |
2409 request_.method = "POST"; | 2360 request_.method = "POST"; |
2410 ChunkedUploadDataStream upload_data(0); | 2361 ChunkedUploadDataStream upload_data(0); |
2411 upload_data.AppendData("1", 1, true); | 2362 upload_data.AppendData("1", 1, true); |
2412 | 2363 |
2413 request_.upload_data_stream = &upload_data; | 2364 request_.upload_data_stream = &upload_data; |
2414 | 2365 |
2415 std::unique_ptr<HttpNetworkTransaction> trans( | 2366 std::unique_ptr<HttpNetworkTransaction> trans( |
2416 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); | 2367 new HttpNetworkTransaction(DEFAULT_PRIORITY, session_.get())); |
2417 TestCompletionCallback callback; | 2368 TestCompletionCallback callback; |
2418 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); | 2369 int rv = trans->Start(&request_, callback.callback(), net_log_.bound()); |
2419 EXPECT_EQ(ERR_IO_PENDING, rv); | 2370 EXPECT_EQ(ERR_IO_PENDING, rv); |
2420 EXPECT_NE(OK, callback.WaitForResult()); | 2371 EXPECT_NE(OK, callback.WaitForResult()); |
2421 } | 2372 } |
2422 | 2373 |
2423 } // namespace test | 2374 } // namespace test |
2424 } // namespace net | 2375 } // namespace net |
OLD | NEW |