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 "net/quic/chromium/quic_http_stream.h" | 5 #include "net/quic/chromium/quic_http_stream.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 using testing::_; | 66 using testing::_; |
67 using testing::AnyNumber; | 67 using testing::AnyNumber; |
68 using testing::Return; | 68 using testing::Return; |
69 | 69 |
70 namespace net { | 70 namespace net { |
71 namespace test { | 71 namespace test { |
72 namespace { | 72 namespace { |
73 | 73 |
74 const char kUploadData[] = "Really nifty data!"; | 74 const char kUploadData[] = "Really nifty data!"; |
75 const char kDefaultServerHostName[] = "www.example.org"; | 75 const char kDefaultServerHostName[] = "www.example.org"; |
76 const uint16_t kDefaultServerPort = 80; | 76 const uint16_t kDefaultServerPort = 443; |
77 | 77 |
78 class TestQuicConnection : public QuicConnection { | 78 class TestQuicConnection : public QuicConnection { |
79 public: | 79 public: |
80 TestQuicConnection(const QuicVersionVector& versions, | 80 TestQuicConnection(const QuicVersionVector& versions, |
81 QuicConnectionId connection_id, | 81 QuicConnectionId connection_id, |
82 IPEndPoint address, | 82 IPEndPoint address, |
83 QuicChromiumConnectionHelper* helper, | 83 QuicChromiumConnectionHelper* helper, |
84 QuicChromiumAlarmFactory* alarm_factory, | 84 QuicChromiumAlarmFactory* alarm_factory, |
85 QuicPacketWriter* writer) | 85 QuicPacketWriter* writer) |
86 : QuicConnection(connection_id, | 86 : QuicConnection(connection_id, |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 | 355 |
356 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); | 356 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); |
357 | 357 |
358 serialized_push_promise_ = | 358 serialized_push_promise_ = |
359 SpdyUtils::SerializeUncompressedHeaders(push_promise_); | 359 SpdyUtils::SerializeUncompressedHeaders(push_promise_); |
360 } | 360 } |
361 | 361 |
362 void SetRequest(const string& method, | 362 void SetRequest(const string& method, |
363 const string& path, | 363 const string& path, |
364 RequestPriority priority) { | 364 RequestPriority priority) { |
365 request_headers_ = client_maker_.GetRequestHeaders(method, "http", path); | 365 request_headers_ = client_maker_.GetRequestHeaders(method, "https", path); |
Bence
2017/04/10 13:37:57
Woo-hoo! Since QUIC requires https in production,
| |
366 } | 366 } |
367 | 367 |
368 void SetResponse(const string& status, const string& body) { | 368 void SetResponse(const string& status, const string& body) { |
369 response_headers_ = server_maker_.GetResponseHeaders(status); | 369 response_headers_ = server_maker_.GetResponseHeaders(status); |
370 response_data_ = body; | 370 response_data_ = body; |
371 } | 371 } |
372 | 372 |
373 std::unique_ptr<QuicReceivedPacket> InnerConstructDataPacket( | 373 std::unique_ptr<QuicReceivedPacket> InnerConstructDataPacket( |
374 QuicPacketNumber packet_number, | 374 QuicPacketNumber packet_number, |
375 QuicStreamId stream_id, | 375 QuicStreamId stream_id, |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, | 639 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, |
640 kDefaultMaxUncompressedHeaderSize, | 640 kDefaultMaxUncompressedHeaderSize, |
641 &header_stream_offset)); | 641 &header_stream_offset)); |
642 AddWrite(InnerConstructRequestHeadersPacket( | 642 AddWrite(InnerConstructRequestHeadersPacket( |
643 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, | 643 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, |
644 &spdy_request_header_frame_length, &header_stream_offset)); | 644 &spdy_request_header_frame_length, &header_stream_offset)); |
645 | 645 |
646 Initialize(); | 646 Initialize(); |
647 | 647 |
648 request_.method = "GET"; | 648 request_.method = "GET"; |
649 request_.url = GURL("http://www.example.org/"); | 649 request_.url = GURL("https://www.example.org/"); |
650 | 650 |
651 // Make sure getting load timing from the stream early does not crash. | 651 // Make sure getting load timing from the stream early does not crash. |
652 LoadTimingInfo load_timing_info; | 652 LoadTimingInfo load_timing_info; |
653 EXPECT_TRUE(stream_->GetLoadTimingInfo(&load_timing_info)); | 653 EXPECT_TRUE(stream_->GetLoadTimingInfo(&load_timing_info)); |
654 | 654 |
655 EXPECT_EQ(OK, | 655 EXPECT_EQ(OK, |
656 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 656 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
657 net_log_.bound(), callback_.callback())); | 657 net_log_.bound(), callback_.callback())); |
658 EXPECT_EQ(OK, | 658 EXPECT_EQ(OK, |
659 stream_->SendRequest(headers_, &response_, callback_.callback())); | 659 stream_->SendRequest(headers_, &response_, callback_.callback())); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
709 // SetRequest() again for second request as |request_headers_| was moved. | 709 // SetRequest() again for second request as |request_headers_| was moved. |
710 SetRequest("GET", "/", DEFAULT_PRIORITY); | 710 SetRequest("GET", "/", DEFAULT_PRIORITY); |
711 AddWrite(InnerConstructRequestHeadersPacket( | 711 AddWrite(InnerConstructRequestHeadersPacket( |
712 3, kClientDataStreamId2, kIncludeVersion, kFin, DEFAULT_PRIORITY, | 712 3, kClientDataStreamId2, kIncludeVersion, kFin, DEFAULT_PRIORITY, |
713 &spdy_request_header_frame_length, &offset)); | 713 &spdy_request_header_frame_length, &offset)); |
714 AddWrite(ConstructClientAckPacket(4, 3, 1)); // Ack the responses. | 714 AddWrite(ConstructClientAckPacket(4, 3, 1)); // Ack the responses. |
715 | 715 |
716 Initialize(); | 716 Initialize(); |
717 | 717 |
718 request_.method = "GET"; | 718 request_.method = "GET"; |
719 request_.url = GURL("http://www.example.org/"); | 719 request_.url = GURL("https://www.example.org/"); |
720 // Start first request. | 720 // Start first request. |
721 EXPECT_EQ(OK, | 721 EXPECT_EQ(OK, |
722 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 722 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
723 net_log_.bound(), callback_.callback())); | 723 net_log_.bound(), callback_.callback())); |
724 EXPECT_EQ(OK, | 724 EXPECT_EQ(OK, |
725 stream_->SendRequest(headers_, &response_, callback_.callback())); | 725 stream_->SendRequest(headers_, &response_, callback_.callback())); |
726 | 726 |
727 // Start a second request. | 727 // Start a second request. |
728 QuicHttpStream stream2(session_->GetWeakPtr(), &http_server_properties_); | 728 QuicHttpStream stream2(session_->GetWeakPtr(), &http_server_properties_); |
729 TestCompletionCallback callback2; | 729 TestCompletionCallback callback2; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
788 kDefaultMaxUncompressedHeaderSize, | 788 kDefaultMaxUncompressedHeaderSize, |
789 &header_stream_offset)); | 789 &header_stream_offset)); |
790 AddWrite(InnerConstructRequestHeadersPacket( | 790 AddWrite(InnerConstructRequestHeadersPacket( |
791 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, | 791 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, |
792 &spdy_request_header_frame_length, &header_stream_offset)); | 792 &spdy_request_header_frame_length, &header_stream_offset)); |
793 AddWrite(ConstructClientAckPacket(3, 3, 1)); // Ack the data packet. | 793 AddWrite(ConstructClientAckPacket(3, 3, 1)); // Ack the data packet. |
794 | 794 |
795 Initialize(); | 795 Initialize(); |
796 | 796 |
797 request_.method = "GET"; | 797 request_.method = "GET"; |
798 request_.url = GURL("http://www.example.org/"); | 798 request_.url = GURL("https://www.example.org/"); |
799 | 799 |
800 EXPECT_EQ(OK, | 800 EXPECT_EQ(OK, |
801 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 801 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
802 net_log_.bound(), callback_.callback())); | 802 net_log_.bound(), callback_.callback())); |
803 | 803 |
804 EXPECT_EQ(OK, | 804 EXPECT_EQ(OK, |
805 stream_->SendRequest(headers_, &response_, callback_.callback())); | 805 stream_->SendRequest(headers_, &response_, callback_.callback())); |
806 // Ack the request. | 806 // Ack the request. |
807 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 807 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
808 | 808 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 QuicStreamOffset header_stream_offset = 0; | 882 QuicStreamOffset header_stream_offset = 0; |
883 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, | 883 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, |
884 kDefaultMaxUncompressedHeaderSize, | 884 kDefaultMaxUncompressedHeaderSize, |
885 &header_stream_offset)); | 885 &header_stream_offset)); |
886 AddWrite(InnerConstructRequestHeadersPacket( | 886 AddWrite(InnerConstructRequestHeadersPacket( |
887 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, | 887 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, |
888 &spdy_request_headers_frame_length, &header_stream_offset)); | 888 &spdy_request_headers_frame_length, &header_stream_offset)); |
889 Initialize(); | 889 Initialize(); |
890 | 890 |
891 request_.method = "GET"; | 891 request_.method = "GET"; |
892 request_.url = GURL("http://www.example.org/"); | 892 request_.url = GURL("https://www.example.org/"); |
893 | 893 |
894 EXPECT_EQ(OK, | 894 EXPECT_EQ(OK, |
895 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 895 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
896 net_log_.bound(), callback_.callback())); | 896 net_log_.bound(), callback_.callback())); |
897 EXPECT_EQ(OK, | 897 EXPECT_EQ(OK, |
898 stream_->SendRequest(headers_, &response_, callback_.callback())); | 898 stream_->SendRequest(headers_, &response_, callback_.callback())); |
899 | 899 |
900 // Ack the request. | 900 // Ack the request. |
901 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 901 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
902 | 902 |
(...skipping 29 matching lines...) Expand all Loading... | |
932 EXPECT_EQ(static_cast<int64_t>(spdy_response_headers_frame_length), | 932 EXPECT_EQ(static_cast<int64_t>(spdy_response_headers_frame_length), |
933 stream_->GetTotalReceivedBytes()); | 933 stream_->GetTotalReceivedBytes()); |
934 } | 934 } |
935 | 935 |
936 // Regression test for http://crbug.com/409101 | 936 // Regression test for http://crbug.com/409101 |
937 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) { | 937 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendRequest) { |
938 SetRequest("GET", "/", DEFAULT_PRIORITY); | 938 SetRequest("GET", "/", DEFAULT_PRIORITY); |
939 Initialize(); | 939 Initialize(); |
940 | 940 |
941 request_.method = "GET"; | 941 request_.method = "GET"; |
942 request_.url = GURL("http://www.example.org/"); | 942 request_.url = GURL("https://www.example.org/"); |
943 | 943 |
944 EXPECT_EQ(OK, | 944 EXPECT_EQ(OK, |
945 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 945 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
946 net_log_.bound(), callback_.callback())); | 946 net_log_.bound(), callback_.callback())); |
947 | 947 |
948 session_->connection()->CloseConnection( | 948 session_->connection()->CloseConnection( |
949 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE); | 949 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE); |
950 | 950 |
951 EXPECT_EQ(ERR_CONNECTION_CLOSED, | 951 EXPECT_EQ(ERR_CONNECTION_CLOSED, |
952 stream_->SendRequest(headers_, &response_, callback_.callback())); | 952 stream_->SendRequest(headers_, &response_, callback_.callback())); |
953 | 953 |
954 EXPECT_EQ(0, stream_->GetTotalSentBytes()); | 954 EXPECT_EQ(0, stream_->GetTotalSentBytes()); |
955 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | 955 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
956 } | 956 } |
957 | 957 |
958 // Regression test for http://crbug.com/584441 | 958 // Regression test for http://crbug.com/584441 |
959 TEST_P(QuicHttpStreamTest, GetSSLInfoAfterSessionClosed) { | 959 TEST_P(QuicHttpStreamTest, GetSSLInfoAfterSessionClosed) { |
960 SetRequest("GET", "/", DEFAULT_PRIORITY); | 960 SetRequest("GET", "/", DEFAULT_PRIORITY); |
961 Initialize(); | 961 Initialize(); |
962 | 962 |
963 request_.method = "GET"; | 963 request_.method = "GET"; |
964 request_.url = GURL("http://www.example.org/"); | 964 request_.url = GURL("https://www.example.org/"); |
965 | 965 |
966 EXPECT_EQ(OK, | 966 EXPECT_EQ(OK, |
967 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 967 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
968 net_log_.bound(), callback_.callback())); | 968 net_log_.bound(), callback_.callback())); |
969 | 969 |
970 SSLInfo ssl_info; | 970 SSLInfo ssl_info; |
971 EXPECT_FALSE(ssl_info.is_valid()); | 971 EXPECT_FALSE(ssl_info.is_valid()); |
972 stream_->GetSSLInfo(&ssl_info); | 972 stream_->GetSSLInfo(&ssl_info); |
973 EXPECT_TRUE(ssl_info.is_valid()); | 973 EXPECT_TRUE(ssl_info.is_valid()); |
974 | 974 |
975 session_->connection()->CloseConnection( | 975 session_->connection()->CloseConnection( |
976 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE); | 976 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE); |
977 | 977 |
978 SSLInfo ssl_info2; | 978 SSLInfo ssl_info2; |
979 stream_->GetSSLInfo(&ssl_info2); | 979 stream_->GetSSLInfo(&ssl_info2); |
980 EXPECT_TRUE(ssl_info2.is_valid()); | 980 EXPECT_TRUE(ssl_info2.is_valid()); |
981 } | 981 } |
982 | 982 |
983 TEST_P(QuicHttpStreamTest, GetAlternativeService) { | |
984 SetRequest("GET", "/", DEFAULT_PRIORITY); | |
985 Initialize(); | |
986 | |
987 request_.method = "GET"; | |
988 request_.url = GURL("https://www.example.org/"); | |
989 | |
990 EXPECT_EQ(OK, | |
991 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | |
992 net_log_.bound(), callback_.callback())); | |
993 | |
994 AlternativeService alternative_service; | |
995 EXPECT_TRUE(stream_->GetAlternativeService(&alternative_service)); | |
996 EXPECT_EQ(AlternativeService(kProtoQUIC, "www.example.org", 443), | |
997 alternative_service) | |
998 << alternative_service.ToString(); | |
Bence
2017/04/10 13:37:57
Please remove this line: I'm making it unnecessary
Ryan Hamilton
2017/04/12 19:44:12
Done.
| |
999 | |
1000 session_->connection()->CloseConnection( | |
1001 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE); | |
1002 | |
1003 AlternativeService alternative_service2; | |
1004 EXPECT_TRUE(stream_->GetAlternativeService(&alternative_service2)); | |
1005 EXPECT_EQ(AlternativeService(kProtoQUIC, "www.example.org", 443), | |
1006 alternative_service2); | |
1007 } | |
1008 | |
983 TEST_P(QuicHttpStreamTest, LogGranularQuicConnectionError) { | 1009 TEST_P(QuicHttpStreamTest, LogGranularQuicConnectionError) { |
984 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1010 SetRequest("GET", "/", DEFAULT_PRIORITY); |
985 size_t spdy_request_headers_frame_length; | 1011 size_t spdy_request_headers_frame_length; |
986 QuicStreamOffset header_stream_offset = 0; | 1012 QuicStreamOffset header_stream_offset = 0; |
987 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, | 1013 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, |
988 kDefaultMaxUncompressedHeaderSize, | 1014 kDefaultMaxUncompressedHeaderSize, |
989 &header_stream_offset)); | 1015 &header_stream_offset)); |
990 AddWrite(InnerConstructRequestHeadersPacket( | 1016 AddWrite(InnerConstructRequestHeadersPacket( |
991 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, | 1017 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, |
992 &spdy_request_headers_frame_length, &header_stream_offset)); | 1018 &spdy_request_headers_frame_length, &header_stream_offset)); |
993 AddWrite(ConstructAckAndRstStreamPacket(3)); | 1019 AddWrite(ConstructAckAndRstStreamPacket(3)); |
994 use_closing_stream_ = true; | 1020 use_closing_stream_ = true; |
995 Initialize(); | 1021 Initialize(); |
996 | 1022 |
997 request_.method = "GET"; | 1023 request_.method = "GET"; |
998 request_.url = GURL("http://www.example.org/"); | 1024 request_.url = GURL("https://www.example.org/"); |
999 | 1025 |
1000 EXPECT_EQ(OK, | 1026 EXPECT_EQ(OK, |
1001 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1027 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1002 net_log_.bound(), callback_.callback())); | 1028 net_log_.bound(), callback_.callback())); |
1003 EXPECT_EQ(OK, | 1029 EXPECT_EQ(OK, |
1004 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1030 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1005 | 1031 |
1006 // Ack the request. | 1032 // Ack the request. |
1007 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 1033 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
1008 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), | 1034 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
(...skipping 19 matching lines...) Expand all Loading... | |
1028 kDefaultMaxUncompressedHeaderSize, | 1054 kDefaultMaxUncompressedHeaderSize, |
1029 &header_stream_offset)); | 1055 &header_stream_offset)); |
1030 AddWrite(InnerConstructRequestHeadersPacket( | 1056 AddWrite(InnerConstructRequestHeadersPacket( |
1031 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, | 1057 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, |
1032 &spdy_request_headers_frame_length, &header_stream_offset)); | 1058 &spdy_request_headers_frame_length, &header_stream_offset)); |
1033 AddWrite(ConstructAckAndRstStreamPacket(3)); | 1059 AddWrite(ConstructAckAndRstStreamPacket(3)); |
1034 use_closing_stream_ = true; | 1060 use_closing_stream_ = true; |
1035 Initialize(); | 1061 Initialize(); |
1036 | 1062 |
1037 request_.method = "GET"; | 1063 request_.method = "GET"; |
1038 request_.url = GURL("http://www.example.org/"); | 1064 request_.url = GURL("https://www.example.org/"); |
1039 | 1065 |
1040 EXPECT_EQ(OK, | 1066 EXPECT_EQ(OK, |
1041 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1067 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1042 net_log_.bound(), callback_.callback())); | 1068 net_log_.bound(), callback_.callback())); |
1043 EXPECT_EQ(OK, | 1069 EXPECT_EQ(OK, |
1044 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1070 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1045 | 1071 |
1046 // Ack the request. | 1072 // Ack the request. |
1047 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 1073 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
1048 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), | 1074 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
(...skipping 22 matching lines...) Expand all Loading... | |
1071 QuicStreamOffset header_stream_offset = 0; | 1097 QuicStreamOffset header_stream_offset = 0; |
1072 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, | 1098 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, |
1073 kDefaultMaxUncompressedHeaderSize, | 1099 kDefaultMaxUncompressedHeaderSize, |
1074 &header_stream_offset)); | 1100 &header_stream_offset)); |
1075 AddWrite(InnerConstructRequestHeadersPacket( | 1101 AddWrite(InnerConstructRequestHeadersPacket( |
1076 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, | 1102 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, |
1077 &spdy_request_headers_frame_length, &header_stream_offset)); | 1103 &spdy_request_headers_frame_length, &header_stream_offset)); |
1078 Initialize(); | 1104 Initialize(); |
1079 | 1105 |
1080 request_.method = "GET"; | 1106 request_.method = "GET"; |
1081 request_.url = GURL("http://www.example.org/"); | 1107 request_.url = GURL("https://www.example.org/"); |
1082 | 1108 |
1083 EXPECT_EQ(OK, | 1109 EXPECT_EQ(OK, |
1084 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1110 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1085 net_log_.bound(), callback_.callback())); | 1111 net_log_.bound(), callback_.callback())); |
1086 | 1112 |
1087 EXPECT_EQ(OK, | 1113 EXPECT_EQ(OK, |
1088 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1114 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1089 | 1115 |
1090 session_->connection()->CloseConnection( | 1116 session_->connection()->CloseConnection( |
1091 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE); | 1117 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE); |
(...skipping 20 matching lines...) Expand all Loading... | |
1112 AddWrite(ConstructClientDataPacket(3, kIncludeVersion, kFin, 0, kUploadData)); | 1138 AddWrite(ConstructClientDataPacket(3, kIncludeVersion, kFin, 0, kUploadData)); |
1113 AddWrite(ConstructClientAckPacket(4, 3, 1)); | 1139 AddWrite(ConstructClientAckPacket(4, 3, 1)); |
1114 | 1140 |
1115 Initialize(); | 1141 Initialize(); |
1116 | 1142 |
1117 std::vector<std::unique_ptr<UploadElementReader>> element_readers; | 1143 std::vector<std::unique_ptr<UploadElementReader>> element_readers; |
1118 element_readers.push_back(base::MakeUnique<UploadBytesElementReader>( | 1144 element_readers.push_back(base::MakeUnique<UploadBytesElementReader>( |
1119 kUploadData, strlen(kUploadData))); | 1145 kUploadData, strlen(kUploadData))); |
1120 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); | 1146 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); |
1121 request_.method = "POST"; | 1147 request_.method = "POST"; |
1122 request_.url = GURL("http://www.example.org/"); | 1148 request_.url = GURL("https://www.example.org/"); |
1123 request_.upload_data_stream = &upload_data_stream; | 1149 request_.upload_data_stream = &upload_data_stream; |
1124 ASSERT_THAT(request_.upload_data_stream->Init(CompletionCallback(), | 1150 ASSERT_THAT(request_.upload_data_stream->Init(CompletionCallback(), |
1125 NetLogWithSource()), | 1151 NetLogWithSource()), |
1126 IsOk()); | 1152 IsOk()); |
1127 | 1153 |
1128 EXPECT_EQ(OK, | 1154 EXPECT_EQ(OK, |
1129 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1155 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1130 net_log_.bound(), callback_.callback())); | 1156 net_log_.bound(), callback_.callback())); |
1131 EXPECT_EQ(OK, | 1157 EXPECT_EQ(OK, |
1132 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1158 stream_->SendRequest(headers_, &response_, callback_.callback())); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1184 ConstructClientDataPacket(3, kIncludeVersion, !kFin, 0, kUploadData)); | 1210 ConstructClientDataPacket(3, kIncludeVersion, !kFin, 0, kUploadData)); |
1185 AddWrite(ConstructClientDataPacket(4, kIncludeVersion, kFin, chunk_size, | 1211 AddWrite(ConstructClientDataPacket(4, kIncludeVersion, kFin, chunk_size, |
1186 kUploadData)); | 1212 kUploadData)); |
1187 AddWrite(ConstructClientAckPacket(5, 3, 1)); | 1213 AddWrite(ConstructClientAckPacket(5, 3, 1)); |
1188 Initialize(); | 1214 Initialize(); |
1189 | 1215 |
1190 ChunkedUploadDataStream upload_data_stream(0); | 1216 ChunkedUploadDataStream upload_data_stream(0); |
1191 upload_data_stream.AppendData(kUploadData, chunk_size, false); | 1217 upload_data_stream.AppendData(kUploadData, chunk_size, false); |
1192 | 1218 |
1193 request_.method = "POST"; | 1219 request_.method = "POST"; |
1194 request_.url = GURL("http://www.example.org/"); | 1220 request_.url = GURL("https://www.example.org/"); |
1195 request_.upload_data_stream = &upload_data_stream; | 1221 request_.upload_data_stream = &upload_data_stream; |
1196 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1222 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1197 TestCompletionCallback().callback(), NetLogWithSource())); | 1223 TestCompletionCallback().callback(), NetLogWithSource())); |
1198 | 1224 |
1199 ASSERT_EQ(OK, | 1225 ASSERT_EQ(OK, |
1200 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1226 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1201 net_log_.bound(), callback_.callback())); | 1227 net_log_.bound(), callback_.callback())); |
1202 ASSERT_EQ(ERR_IO_PENDING, | 1228 ASSERT_EQ(ERR_IO_PENDING, |
1203 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1229 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1204 | 1230 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1259 AddWrite( | 1285 AddWrite( |
1260 ConstructClientDataPacket(3, kIncludeVersion, !kFin, 0, kUploadData)); | 1286 ConstructClientDataPacket(3, kIncludeVersion, !kFin, 0, kUploadData)); |
1261 AddWrite(ConstructClientDataPacket(4, kIncludeVersion, kFin, chunk_size, "")); | 1287 AddWrite(ConstructClientDataPacket(4, kIncludeVersion, kFin, chunk_size, "")); |
1262 AddWrite(ConstructClientAckPacket(5, 3, 1)); | 1288 AddWrite(ConstructClientAckPacket(5, 3, 1)); |
1263 Initialize(); | 1289 Initialize(); |
1264 | 1290 |
1265 ChunkedUploadDataStream upload_data_stream(0); | 1291 ChunkedUploadDataStream upload_data_stream(0); |
1266 upload_data_stream.AppendData(kUploadData, chunk_size, false); | 1292 upload_data_stream.AppendData(kUploadData, chunk_size, false); |
1267 | 1293 |
1268 request_.method = "POST"; | 1294 request_.method = "POST"; |
1269 request_.url = GURL("http://www.example.org/"); | 1295 request_.url = GURL("https://www.example.org/"); |
1270 request_.upload_data_stream = &upload_data_stream; | 1296 request_.upload_data_stream = &upload_data_stream; |
1271 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1297 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1272 TestCompletionCallback().callback(), NetLogWithSource())); | 1298 TestCompletionCallback().callback(), NetLogWithSource())); |
1273 | 1299 |
1274 ASSERT_EQ(OK, | 1300 ASSERT_EQ(OK, |
1275 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1301 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1276 net_log_.bound(), callback_.callback())); | 1302 net_log_.bound(), callback_.callback())); |
1277 ASSERT_EQ(ERR_IO_PENDING, | 1303 ASSERT_EQ(ERR_IO_PENDING, |
1278 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1304 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1279 | 1305 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1328 AddWrite(InnerConstructRequestHeadersPacket( | 1354 AddWrite(InnerConstructRequestHeadersPacket( |
1329 2, kClientDataStreamId1, kIncludeVersion, !kFin, DEFAULT_PRIORITY, | 1355 2, kClientDataStreamId1, kIncludeVersion, !kFin, DEFAULT_PRIORITY, |
1330 &spdy_request_headers_frame_length, &header_stream_offset)); | 1356 &spdy_request_headers_frame_length, &header_stream_offset)); |
1331 AddWrite(ConstructClientDataPacket(3, kIncludeVersion, kFin, 0, "")); | 1357 AddWrite(ConstructClientDataPacket(3, kIncludeVersion, kFin, 0, "")); |
1332 AddWrite(ConstructClientAckPacket(4, 3, 1)); | 1358 AddWrite(ConstructClientAckPacket(4, 3, 1)); |
1333 Initialize(); | 1359 Initialize(); |
1334 | 1360 |
1335 ChunkedUploadDataStream upload_data_stream(0); | 1361 ChunkedUploadDataStream upload_data_stream(0); |
1336 | 1362 |
1337 request_.method = "POST"; | 1363 request_.method = "POST"; |
1338 request_.url = GURL("http://www.example.org/"); | 1364 request_.url = GURL("https://www.example.org/"); |
1339 request_.upload_data_stream = &upload_data_stream; | 1365 request_.upload_data_stream = &upload_data_stream; |
1340 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1366 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1341 TestCompletionCallback().callback(), NetLogWithSource())); | 1367 TestCompletionCallback().callback(), NetLogWithSource())); |
1342 | 1368 |
1343 ASSERT_EQ(OK, | 1369 ASSERT_EQ(OK, |
1344 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1370 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1345 net_log_.bound(), callback_.callback())); | 1371 net_log_.bound(), callback_.callback())); |
1346 ASSERT_EQ(ERR_IO_PENDING, | 1372 ASSERT_EQ(ERR_IO_PENDING, |
1347 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1373 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1348 | 1374 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1395 kDefaultMaxUncompressedHeaderSize, | 1421 kDefaultMaxUncompressedHeaderSize, |
1396 &header_stream_offset)); | 1422 &header_stream_offset)); |
1397 AddWrite(InnerConstructRequestHeadersPacket( | 1423 AddWrite(InnerConstructRequestHeadersPacket( |
1398 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, | 1424 2, kClientDataStreamId1, kIncludeVersion, kFin, DEFAULT_PRIORITY, |
1399 &spdy_request_headers_frame_length, &header_stream_offset)); | 1425 &spdy_request_headers_frame_length, &header_stream_offset)); |
1400 AddWrite(ConstructAckAndRstStreamPacket(3)); | 1426 AddWrite(ConstructAckAndRstStreamPacket(3)); |
1401 use_closing_stream_ = true; | 1427 use_closing_stream_ = true; |
1402 Initialize(); | 1428 Initialize(); |
1403 | 1429 |
1404 request_.method = "GET"; | 1430 request_.method = "GET"; |
1405 request_.url = GURL("http://www.example.org/"); | 1431 request_.url = GURL("https://www.example.org/"); |
1406 | 1432 |
1407 EXPECT_EQ(OK, | 1433 EXPECT_EQ(OK, |
1408 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1434 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1409 net_log_.bound(), callback_.callback())); | 1435 net_log_.bound(), callback_.callback())); |
1410 EXPECT_EQ(OK, | 1436 EXPECT_EQ(OK, |
1411 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1437 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1412 | 1438 |
1413 // Ack the request. | 1439 // Ack the request. |
1414 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 1440 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
1415 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), | 1441 EXPECT_THAT(stream_->ReadResponseHeaders(callback_.callback()), |
(...skipping 24 matching lines...) Expand all Loading... | |
1440 kDefaultMaxUncompressedHeaderSize, | 1466 kDefaultMaxUncompressedHeaderSize, |
1441 &header_stream_offset)); | 1467 &header_stream_offset)); |
1442 AddWrite(InnerConstructRequestHeadersPacket( | 1468 AddWrite(InnerConstructRequestHeadersPacket( |
1443 2, kClientDataStreamId1, kIncludeVersion, kFin, MEDIUM, | 1469 2, kClientDataStreamId1, kIncludeVersion, kFin, MEDIUM, |
1444 &spdy_request_headers_frame_length, &header_stream_offset)); | 1470 &spdy_request_headers_frame_length, &header_stream_offset)); |
1445 AddWrite(ConstructAckAndRstStreamPacket(3)); | 1471 AddWrite(ConstructAckAndRstStreamPacket(3)); |
1446 use_closing_stream_ = true; | 1472 use_closing_stream_ = true; |
1447 Initialize(); | 1473 Initialize(); |
1448 | 1474 |
1449 request_.method = "GET"; | 1475 request_.method = "GET"; |
1450 request_.url = GURL("http://www.example.org/"); | 1476 request_.url = GURL("https://www.example.org/"); |
1451 | 1477 |
1452 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_.bound(), | 1478 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_.bound(), |
1453 callback_.callback())); | 1479 callback_.callback())); |
1454 | 1480 |
1455 // Check that priority is highest. | 1481 // Check that priority is highest. |
1456 QuicChromiumClientStream* reliable_stream = | 1482 QuicChromiumClientStream* reliable_stream = |
1457 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); | 1483 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); |
1458 DCHECK(reliable_stream); | 1484 DCHECK(reliable_stream); |
1459 DCHECK_EQ(kV3HighestPriority, reliable_stream->priority()); | 1485 DCHECK_EQ(kV3HighestPriority, reliable_stream->priority()); |
1460 | 1486 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1493 use_closing_stream_ = true; | 1519 use_closing_stream_ = true; |
1494 QuicStreamOffset header_stream_offset = 0; | 1520 QuicStreamOffset header_stream_offset = 0; |
1495 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, | 1521 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, |
1496 kDefaultMaxUncompressedHeaderSize, | 1522 kDefaultMaxUncompressedHeaderSize, |
1497 &header_stream_offset)); | 1523 &header_stream_offset)); |
1498 AddWrite(ConstructClientRstStreamPacket(2)); | 1524 AddWrite(ConstructClientRstStreamPacket(2)); |
1499 | 1525 |
1500 Initialize(); | 1526 Initialize(); |
1501 | 1527 |
1502 request_.method = "GET"; | 1528 request_.method = "GET"; |
1503 request_.url = GURL("http://www.example.org/"); | 1529 request_.url = GURL("https://www.example.org/"); |
1504 | 1530 |
1505 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_.bound(), | 1531 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, net_log_.bound(), |
1506 callback_.callback())); | 1532 callback_.callback())); |
1507 | 1533 |
1508 // Check that priority is highest. | 1534 // Check that priority is highest. |
1509 QuicChromiumClientStream* reliable_stream = | 1535 QuicChromiumClientStream* reliable_stream = |
1510 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); | 1536 QuicHttpStreamPeer::GetQuicChromiumClientStream(stream_.get()); |
1511 DCHECK(reliable_stream); | 1537 DCHECK(reliable_stream); |
1512 QuicChromiumClientStream::Delegate* delegate = reliable_stream->GetDelegate(); | 1538 QuicChromiumClientStream::Delegate* delegate = reliable_stream->GetDelegate(); |
1513 DCHECK(delegate); | 1539 DCHECK(delegate); |
(...skipping 22 matching lines...) Expand all Loading... | |
1536 AddWrite( | 1562 AddWrite( |
1537 ConstructClientDataPacket(3, kIncludeVersion, !kFin, 0, kUploadData)); | 1563 ConstructClientDataPacket(3, kIncludeVersion, !kFin, 0, kUploadData)); |
1538 // Second data write will result in a synchronous failure which will close | 1564 // Second data write will result in a synchronous failure which will close |
1539 // the session. | 1565 // the session. |
1540 AddWrite(SYNCHRONOUS, ERR_FAILED); | 1566 AddWrite(SYNCHRONOUS, ERR_FAILED); |
1541 Initialize(); | 1567 Initialize(); |
1542 | 1568 |
1543 ChunkedUploadDataStream upload_data_stream(0); | 1569 ChunkedUploadDataStream upload_data_stream(0); |
1544 | 1570 |
1545 request_.method = "POST"; | 1571 request_.method = "POST"; |
1546 request_.url = GURL("http://www.example.org/"); | 1572 request_.url = GURL("https://www.example.org/"); |
1547 request_.upload_data_stream = &upload_data_stream; | 1573 request_.upload_data_stream = &upload_data_stream; |
1548 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1574 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1549 TestCompletionCallback().callback(), NetLogWithSource())); | 1575 TestCompletionCallback().callback(), NetLogWithSource())); |
1550 | 1576 |
1551 size_t chunk_size = strlen(kUploadData); | 1577 size_t chunk_size = strlen(kUploadData); |
1552 upload_data_stream.AppendData(kUploadData, chunk_size, false); | 1578 upload_data_stream.AppendData(kUploadData, chunk_size, false); |
1553 ASSERT_EQ(OK, | 1579 ASSERT_EQ(OK, |
1554 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1580 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1555 net_log_.bound(), callback_.callback())); | 1581 net_log_.bound(), callback_.callback())); |
1556 QuicHttpStream* stream = stream_.get(); | 1582 QuicHttpStream* stream = stream_.get(); |
(...skipping 11 matching lines...) Expand all Loading... | |
1568 QuicStreamOffset header_stream_offset = 0; | 1594 QuicStreamOffset header_stream_offset = 0; |
1569 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, | 1595 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, |
1570 kDefaultMaxUncompressedHeaderSize, | 1596 kDefaultMaxUncompressedHeaderSize, |
1571 &header_stream_offset)); | 1597 &header_stream_offset)); |
1572 AddWrite(SYNCHRONOUS, ERR_FAILED); | 1598 AddWrite(SYNCHRONOUS, ERR_FAILED); |
1573 Initialize(); | 1599 Initialize(); |
1574 | 1600 |
1575 ChunkedUploadDataStream upload_data_stream(0); | 1601 ChunkedUploadDataStream upload_data_stream(0); |
1576 | 1602 |
1577 request_.method = "POST"; | 1603 request_.method = "POST"; |
1578 request_.url = GURL("http://www.example.org/"); | 1604 request_.url = GURL("https://www.example.org/"); |
1579 request_.upload_data_stream = &upload_data_stream; | 1605 request_.upload_data_stream = &upload_data_stream; |
1580 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1606 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1581 TestCompletionCallback().callback(), NetLogWithSource())); | 1607 TestCompletionCallback().callback(), NetLogWithSource())); |
1582 | 1608 |
1583 ASSERT_EQ(OK, | 1609 ASSERT_EQ(OK, |
1584 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1610 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1585 net_log_.bound(), callback_.callback())); | 1611 net_log_.bound(), callback_.callback())); |
1586 ASSERT_EQ(ERR_QUIC_PROTOCOL_ERROR, | 1612 ASSERT_EQ(ERR_QUIC_PROTOCOL_ERROR, |
1587 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1613 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1588 } | 1614 } |
1589 | 1615 |
1590 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendBodyComplete) { | 1616 TEST_P(QuicHttpStreamTest, SessionClosedBeforeSendBodyComplete) { |
1591 SetRequest("POST", "/", DEFAULT_PRIORITY); | 1617 SetRequest("POST", "/", DEFAULT_PRIORITY); |
1592 size_t spdy_request_headers_frame_length; | 1618 size_t spdy_request_headers_frame_length; |
1593 QuicStreamOffset header_stream_offset = 0; | 1619 QuicStreamOffset header_stream_offset = 0; |
1594 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, | 1620 AddWrite(ConstructSettingsPacket(1, SETTINGS_MAX_HEADER_LIST_SIZE, |
1595 kDefaultMaxUncompressedHeaderSize, | 1621 kDefaultMaxUncompressedHeaderSize, |
1596 &header_stream_offset)); | 1622 &header_stream_offset)); |
1597 AddWrite(InnerConstructRequestHeadersPacket( | 1623 AddWrite(InnerConstructRequestHeadersPacket( |
1598 2, kClientDataStreamId1, kIncludeVersion, !kFin, DEFAULT_PRIORITY, | 1624 2, kClientDataStreamId1, kIncludeVersion, !kFin, DEFAULT_PRIORITY, |
1599 &spdy_request_headers_frame_length, &header_stream_offset)); | 1625 &spdy_request_headers_frame_length, &header_stream_offset)); |
1600 AddWrite(SYNCHRONOUS, ERR_FAILED); | 1626 AddWrite(SYNCHRONOUS, ERR_FAILED); |
1601 Initialize(); | 1627 Initialize(); |
1602 | 1628 |
1603 ChunkedUploadDataStream upload_data_stream(0); | 1629 ChunkedUploadDataStream upload_data_stream(0); |
1604 size_t chunk_size = strlen(kUploadData); | 1630 size_t chunk_size = strlen(kUploadData); |
1605 upload_data_stream.AppendData(kUploadData, chunk_size, false); | 1631 upload_data_stream.AppendData(kUploadData, chunk_size, false); |
1606 | 1632 |
1607 request_.method = "POST"; | 1633 request_.method = "POST"; |
1608 request_.url = GURL("http://www.example.org/"); | 1634 request_.url = GURL("https://www.example.org/"); |
1609 request_.upload_data_stream = &upload_data_stream; | 1635 request_.upload_data_stream = &upload_data_stream; |
1610 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 1636 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
1611 TestCompletionCallback().callback(), NetLogWithSource())); | 1637 TestCompletionCallback().callback(), NetLogWithSource())); |
1612 | 1638 |
1613 ASSERT_EQ(OK, | 1639 ASSERT_EQ(OK, |
1614 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1640 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1615 net_log_.bound(), callback_.callback())); | 1641 net_log_.bound(), callback_.callback())); |
1616 ASSERT_EQ(ERR_QUIC_PROTOCOL_ERROR, | 1642 ASSERT_EQ(ERR_QUIC_PROTOCOL_ERROR, |
1617 stream_->SendRequest(headers_, &response_, callback_.callback())); | 1643 stream_->SendRequest(headers_, &response_, callback_.callback())); |
1618 } | 1644 } |
1619 | 1645 |
1620 TEST_P(QuicHttpStreamTest, ServerPushGetRequest) { | 1646 TEST_P(QuicHttpStreamTest, ServerPushGetRequest) { |
1621 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1647 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1622 Initialize(); | 1648 Initialize(); |
1623 | 1649 |
1624 // Initialize the first stream, for receiving the promise on. | 1650 // Initialize the first stream, for receiving the promise on. |
1625 request_.method = "GET"; | 1651 request_.method = "GET"; |
1626 request_.url = GURL("http://www.example.org/"); | 1652 request_.url = GURL("https://www.example.org/"); |
1627 | 1653 |
1628 EXPECT_EQ(OK, | 1654 EXPECT_EQ(OK, |
1629 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1655 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1630 net_log_.bound(), callback_.callback())); | 1656 net_log_.bound(), callback_.callback())); |
1631 | 1657 |
1632 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1658 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1633 // packet, but does it matter? | 1659 // packet, but does it matter? |
1634 ReceivePromise(promise_id_); | 1660 ReceivePromise(promise_id_); |
1635 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 1661 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
1636 | 1662 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1682 strlen(kResponseBody)), | 1708 strlen(kResponseBody)), |
1683 promised_stream_->GetTotalReceivedBytes()); | 1709 promised_stream_->GetTotalReceivedBytes()); |
1684 } | 1710 } |
1685 | 1711 |
1686 TEST_P(QuicHttpStreamTest, ServerPushGetRequestSlowResponse) { | 1712 TEST_P(QuicHttpStreamTest, ServerPushGetRequestSlowResponse) { |
1687 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1713 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1688 Initialize(); | 1714 Initialize(); |
1689 | 1715 |
1690 // Initialize the first stream, for receiving the promise on. | 1716 // Initialize the first stream, for receiving the promise on. |
1691 request_.method = "GET"; | 1717 request_.method = "GET"; |
1692 request_.url = GURL("http://www.example.org/"); | 1718 request_.url = GURL("https://www.example.org/"); |
1693 | 1719 |
1694 EXPECT_EQ(OK, | 1720 EXPECT_EQ(OK, |
1695 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1721 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1696 net_log_.bound(), callback_.callback())); | 1722 net_log_.bound(), callback_.callback())); |
1697 | 1723 |
1698 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1724 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1699 // packet, but does it matter? | 1725 // packet, but does it matter? |
1700 ReceivePromise(promise_id_); | 1726 ReceivePromise(promise_id_); |
1701 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 1727 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
1702 | 1728 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1756 promised_stream_->GetTotalReceivedBytes()); | 1782 promised_stream_->GetTotalReceivedBytes()); |
1757 } | 1783 } |
1758 | 1784 |
1759 // Verify fix for crbug.com/637349 | 1785 // Verify fix for crbug.com/637349 |
1760 TEST_P(QuicHttpStreamTest, ServerPushCancelHttpStreamBeforeResponse) { | 1786 TEST_P(QuicHttpStreamTest, ServerPushCancelHttpStreamBeforeResponse) { |
1761 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1787 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1762 Initialize(); | 1788 Initialize(); |
1763 | 1789 |
1764 // Initialize the first stream, for receiving the promise on. | 1790 // Initialize the first stream, for receiving the promise on. |
1765 request_.method = "GET"; | 1791 request_.method = "GET"; |
1766 request_.url = GURL("http://www.example.org/"); | 1792 request_.url = GURL("https://www.example.org/"); |
1767 | 1793 |
1768 EXPECT_EQ(OK, | 1794 EXPECT_EQ(OK, |
1769 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1795 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1770 net_log_.bound(), callback_.callback())); | 1796 net_log_.bound(), callback_.callback())); |
1771 | 1797 |
1772 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1798 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1773 // packet, but does it matter? | 1799 // packet, but does it matter? |
1774 ReceivePromise(promise_id_); | 1800 ReceivePromise(promise_id_); |
1775 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 1801 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
1776 | 1802 |
(...skipping 21 matching lines...) Expand all Loading... | |
1798 ProcessPacket(InnerConstructResponseHeadersPacket( | 1824 ProcessPacket(InnerConstructResponseHeadersPacket( |
1799 1, promise_id_, false, &spdy_response_headers_frame_length)); | 1825 1, promise_id_, false, &spdy_response_headers_frame_length)); |
1800 } | 1826 } |
1801 | 1827 |
1802 TEST_P(QuicHttpStreamTest, ServerPushCrossOriginOK) { | 1828 TEST_P(QuicHttpStreamTest, ServerPushCrossOriginOK) { |
1803 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1829 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1804 Initialize(); | 1830 Initialize(); |
1805 | 1831 |
1806 // Initialize the first stream, for receiving the promise on. | 1832 // Initialize the first stream, for receiving the promise on. |
1807 request_.method = "GET"; | 1833 request_.method = "GET"; |
1808 request_.url = GURL("http://www.example.org/"); | 1834 request_.url = GURL("https://www.example.org/"); |
1809 | 1835 |
1810 EXPECT_EQ(OK, | 1836 EXPECT_EQ(OK, |
1811 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1837 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1812 net_log_.bound(), callback_.callback())); | 1838 net_log_.bound(), callback_.callback())); |
1813 | 1839 |
1814 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1840 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1815 // packet, but does it matter? | 1841 // packet, but does it matter? |
1816 | 1842 |
1817 push_promise_[":authority"] = "mail.example.org"; | 1843 push_promise_[":authority"] = "mail.example.org"; |
1818 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); | 1844 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1870 strlen(kResponseBody)), | 1896 strlen(kResponseBody)), |
1871 promised_stream_->GetTotalReceivedBytes()); | 1897 promised_stream_->GetTotalReceivedBytes()); |
1872 } | 1898 } |
1873 | 1899 |
1874 TEST_P(QuicHttpStreamTest, ServerPushCrossOriginFail) { | 1900 TEST_P(QuicHttpStreamTest, ServerPushCrossOriginFail) { |
1875 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1901 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1876 Initialize(); | 1902 Initialize(); |
1877 | 1903 |
1878 // Initialize the first stream, for receiving the promise on. | 1904 // Initialize the first stream, for receiving the promise on. |
1879 request_.method = "GET"; | 1905 request_.method = "GET"; |
1880 request_.url = GURL("http://www.example.org/"); | 1906 request_.url = GURL("https://www.example.org/"); |
1881 | 1907 |
1882 EXPECT_EQ(OK, | 1908 EXPECT_EQ(OK, |
1883 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1909 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1884 net_log_.bound(), callback_.callback())); | 1910 net_log_.bound(), callback_.callback())); |
1885 | 1911 |
1886 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1912 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
1887 // packet, but does it matter? | 1913 // packet, but does it matter? |
1888 push_promise_[":authority"] = "www.notexample.org"; | 1914 push_promise_[":authority"] = "www.notexample.org"; |
1889 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); | 1915 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); |
1890 serialized_push_promise_ = | 1916 serialized_push_promise_ = |
1891 SpdyUtils::SerializeUncompressedHeaders(push_promise_); | 1917 SpdyUtils::SerializeUncompressedHeaders(push_promise_); |
1892 | 1918 |
1893 ReceivePromise(promise_id_); | 1919 ReceivePromise(promise_id_); |
1894 // The promise will have been rejected because the cert doesn't | 1920 // The promise will have been rejected because the cert doesn't |
1895 // match. | 1921 // match. |
1896 EXPECT_EQ(session_->GetPromisedByUrl(promise_url_), nullptr); | 1922 EXPECT_EQ(session_->GetPromisedByUrl(promise_url_), nullptr); |
1897 } | 1923 } |
1898 | 1924 |
1899 TEST_P(QuicHttpStreamTest, ServerPushVaryCheckOK) { | 1925 TEST_P(QuicHttpStreamTest, ServerPushVaryCheckOK) { |
1900 SetRequest("GET", "/", DEFAULT_PRIORITY); | 1926 SetRequest("GET", "/", DEFAULT_PRIORITY); |
1901 Initialize(); | 1927 Initialize(); |
1902 | 1928 |
1903 // Initialize the first stream, for receiving the promise on. | 1929 // Initialize the first stream, for receiving the promise on. |
1904 request_.method = "GET"; | 1930 request_.method = "GET"; |
1905 request_.url = GURL("http://www.example.org/"); | 1931 request_.url = GURL("https://www.example.org/"); |
1906 | 1932 |
1907 EXPECT_EQ(OK, | 1933 EXPECT_EQ(OK, |
1908 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 1934 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
1909 net_log_.bound(), callback_.callback())); | 1935 net_log_.bound(), callback_.callback())); |
1910 | 1936 |
1911 push_promise_["accept-encoding"] = "gzip"; | 1937 push_promise_["accept-encoding"] = "gzip"; |
1912 serialized_push_promise_ = | 1938 serialized_push_promise_ = |
1913 SpdyUtils::SerializeUncompressedHeaders(push_promise_); | 1939 SpdyUtils::SerializeUncompressedHeaders(push_promise_); |
1914 | 1940 |
1915 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 1941 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1990 AddWrite(ConstructClientRstStreamVaryMismatchPacket(2)); | 2016 AddWrite(ConstructClientRstStreamVaryMismatchPacket(2)); |
1991 AddWrite(InnerConstructRequestHeadersPacket( | 2017 AddWrite(InnerConstructRequestHeadersPacket( |
1992 3, stream_id_ + 2, !kIncludeVersion, kFin, DEFAULT_PRIORITY, | 2018 3, stream_id_ + 2, !kIncludeVersion, kFin, DEFAULT_PRIORITY, |
1993 &spdy_request_header_frame_length, &header_stream_offset)); | 2019 &spdy_request_header_frame_length, &header_stream_offset)); |
1994 AddWrite(ConstructClientAckPacket(4, 3, 1)); | 2020 AddWrite(ConstructClientAckPacket(4, 3, 1)); |
1995 AddWrite(ConstructClientRstStreamCancelledPacket(5)); | 2021 AddWrite(ConstructClientRstStreamCancelledPacket(5)); |
1996 Initialize(); | 2022 Initialize(); |
1997 | 2023 |
1998 // Initialize the first stream, for receiving the promise on. | 2024 // Initialize the first stream, for receiving the promise on. |
1999 request_.method = "GET"; | 2025 request_.method = "GET"; |
2000 request_.url = GURL("http://www.example.org/"); | 2026 request_.url = GURL("https://www.example.org/"); |
2001 | 2027 |
2002 EXPECT_EQ(OK, | 2028 EXPECT_EQ(OK, |
2003 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 2029 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
2004 net_log_.bound(), callback_.callback())); | 2030 net_log_.bound(), callback_.callback())); |
2005 | 2031 |
2006 push_promise_["accept-encoding"] = "gzip"; | 2032 push_promise_["accept-encoding"] = "gzip"; |
2007 serialized_push_promise_ = | 2033 serialized_push_promise_ = |
2008 SpdyUtils::SerializeUncompressedHeaders(push_promise_); | 2034 SpdyUtils::SerializeUncompressedHeaders(push_promise_); |
2009 | 2035 |
2010 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE | 2036 // TODO(ckrasic) - could do this via constructing a PUSH_PROMISE |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2105 AddWrite(InnerConstructRequestHeadersPacket( | 2131 AddWrite(InnerConstructRequestHeadersPacket( |
2106 2, kClientDataStreamId1, kIncludeVersion, !kFin, DEFAULT_PRIORITY, | 2132 2, kClientDataStreamId1, kIncludeVersion, !kFin, DEFAULT_PRIORITY, |
2107 &spdy_request_headers_frame_length, &header_stream_offset)); | 2133 &spdy_request_headers_frame_length, &header_stream_offset)); |
2108 AddWrite(ConstructClientRstStreamErrorPacket(3, kIncludeVersion)); | 2134 AddWrite(ConstructClientRstStreamErrorPacket(3, kIncludeVersion)); |
2109 | 2135 |
2110 Initialize(); | 2136 Initialize(); |
2111 | 2137 |
2112 ReadErrorUploadDataStream upload_data_stream( | 2138 ReadErrorUploadDataStream upload_data_stream( |
2113 ReadErrorUploadDataStream::FailureMode::SYNC); | 2139 ReadErrorUploadDataStream::FailureMode::SYNC); |
2114 request_.method = "POST"; | 2140 request_.method = "POST"; |
2115 request_.url = GURL("http://www.example.org/"); | 2141 request_.url = GURL("https://www.example.org/"); |
2116 request_.upload_data_stream = &upload_data_stream; | 2142 request_.upload_data_stream = &upload_data_stream; |
2117 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 2143 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
2118 TestCompletionCallback().callback(), NetLogWithSource())); | 2144 TestCompletionCallback().callback(), NetLogWithSource())); |
2119 | 2145 |
2120 EXPECT_EQ(OK, | 2146 EXPECT_EQ(OK, |
2121 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 2147 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
2122 net_log_.bound(), callback_.callback())); | 2148 net_log_.bound(), callback_.callback())); |
2123 | 2149 |
2124 int result = stream_->SendRequest(headers_, &response_, callback_.callback()); | 2150 int result = stream_->SendRequest(headers_, &response_, callback_.callback()); |
2125 EXPECT_THAT(result, IsError(ERR_FAILED)); | 2151 EXPECT_THAT(result, IsError(ERR_FAILED)); |
(...skipping 16 matching lines...) Expand all Loading... | |
2142 AddWrite(InnerConstructRequestHeadersPacket( | 2168 AddWrite(InnerConstructRequestHeadersPacket( |
2143 2, kClientDataStreamId1, kIncludeVersion, !kFin, DEFAULT_PRIORITY, | 2169 2, kClientDataStreamId1, kIncludeVersion, !kFin, DEFAULT_PRIORITY, |
2144 &spdy_request_headers_frame_length, &header_stream_offset)); | 2170 &spdy_request_headers_frame_length, &header_stream_offset)); |
2145 AddWrite(ConstructClientRstStreamErrorPacket(3, !kIncludeVersion)); | 2171 AddWrite(ConstructClientRstStreamErrorPacket(3, !kIncludeVersion)); |
2146 | 2172 |
2147 Initialize(); | 2173 Initialize(); |
2148 | 2174 |
2149 ReadErrorUploadDataStream upload_data_stream( | 2175 ReadErrorUploadDataStream upload_data_stream( |
2150 ReadErrorUploadDataStream::FailureMode::ASYNC); | 2176 ReadErrorUploadDataStream::FailureMode::ASYNC); |
2151 request_.method = "POST"; | 2177 request_.method = "POST"; |
2152 request_.url = GURL("http://www.example.org/"); | 2178 request_.url = GURL("https://www.example.org/"); |
2153 request_.upload_data_stream = &upload_data_stream; | 2179 request_.upload_data_stream = &upload_data_stream; |
2154 ASSERT_EQ(OK, request_.upload_data_stream->Init( | 2180 ASSERT_EQ(OK, request_.upload_data_stream->Init( |
2155 TestCompletionCallback().callback(), NetLogWithSource())); | 2181 TestCompletionCallback().callback(), NetLogWithSource())); |
2156 | 2182 |
2157 EXPECT_EQ(OK, | 2183 EXPECT_EQ(OK, |
2158 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 2184 stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
2159 net_log_.bound(), callback_.callback())); | 2185 net_log_.bound(), callback_.callback())); |
2160 | 2186 |
2161 int result = stream_->SendRequest(headers_, &response_, callback_.callback()); | 2187 int result = stream_->SendRequest(headers_, &response_, callback_.callback()); |
2162 | 2188 |
2163 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); | 2189 ProcessPacket(ConstructServerAckPacket(1, 0, 0)); |
2164 SetResponse("200 OK", string()); | 2190 SetResponse("200 OK", string()); |
2165 | 2191 |
2166 EXPECT_THAT(result, IsError(ERR_IO_PENDING)); | 2192 EXPECT_THAT(result, IsError(ERR_IO_PENDING)); |
2167 EXPECT_THAT(callback_.GetResult(result), IsError(ERR_FAILED)); | 2193 EXPECT_THAT(callback_.GetResult(result), IsError(ERR_FAILED)); |
2168 | 2194 |
2169 EXPECT_TRUE(AtEof()); | 2195 EXPECT_TRUE(AtEof()); |
2170 | 2196 |
2171 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. | 2197 // QuicHttpStream::GetTotalSent/ReceivedBytes includes only headers. |
2172 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), | 2198 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), |
2173 stream_->GetTotalSentBytes()); | 2199 stream_->GetTotalSentBytes()); |
2174 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); | 2200 EXPECT_EQ(0, stream_->GetTotalReceivedBytes()); |
2175 } | 2201 } |
2176 | 2202 |
2177 } // namespace test | 2203 } // namespace test |
2178 } // namespace net | 2204 } // namespace net |
OLD | NEW |