| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/quic_spdy_stream.h" | 5 #include "net/quic/quic_spdy_stream.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 | 8 |
| 9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
| 10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 stream_->OnStreamHeaders(headers); | 131 stream_->OnStreamHeaders(headers); |
| 132 EXPECT_EQ("", stream_->data()); | 132 EXPECT_EQ("", stream_->data()); |
| 133 EXPECT_EQ(headers, stream_->decompressed_headers()); | 133 EXPECT_EQ(headers, stream_->decompressed_headers()); |
| 134 stream_->OnStreamHeadersComplete(false, headers.size()); | 134 stream_->OnStreamHeadersComplete(false, headers.size()); |
| 135 EXPECT_EQ(kV3HighestPriority, stream_->priority()); | 135 EXPECT_EQ(kV3HighestPriority, stream_->priority()); |
| 136 EXPECT_EQ("", stream_->data()); | 136 EXPECT_EQ("", stream_->data()); |
| 137 EXPECT_EQ(headers, stream_->decompressed_headers()); | 137 EXPECT_EQ(headers, stream_->decompressed_headers()); |
| 138 EXPECT_FALSE(stream_->IsDoneReading()); | 138 EXPECT_FALSE(stream_->IsDoneReading()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 TEST_P(QuicSpdyStreamTest, ProcessHeaderList) { |
| 142 Initialize(kShouldProcessData); |
| 143 |
| 144 size_t total_bytes = 0; |
| 145 QuicHeaderList headers; |
| 146 for (auto p : headers_) { |
| 147 headers.OnHeader(p.first, p.second); |
| 148 total_bytes += p.first.size() + p.second.size(); |
| 149 } |
| 150 stream_->OnStreamHeadersPriority(kV3HighestPriority); |
| 151 stream_->OnStreamHeaderList(false, total_bytes, headers); |
| 152 EXPECT_EQ("", stream_->data()); |
| 153 EXPECT_FALSE(stream_->header_list().empty()); |
| 154 EXPECT_FALSE(stream_->IsDoneReading()); |
| 155 } |
| 156 |
| 141 TEST_P(QuicSpdyStreamTest, ProcessHeadersWithFin) { | 157 TEST_P(QuicSpdyStreamTest, ProcessHeadersWithFin) { |
| 142 Initialize(kShouldProcessData); | 158 Initialize(kShouldProcessData); |
| 143 | 159 |
| 144 string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); | 160 string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
| 145 stream_->OnStreamHeadersPriority(kV3HighestPriority); | 161 stream_->OnStreamHeadersPriority(kV3HighestPriority); |
| 146 stream_->OnStreamHeaders(headers); | 162 stream_->OnStreamHeaders(headers); |
| 147 EXPECT_EQ("", stream_->data()); | 163 EXPECT_EQ("", stream_->data()); |
| 148 EXPECT_EQ(headers, stream_->decompressed_headers()); | 164 EXPECT_EQ(headers, stream_->decompressed_headers()); |
| 149 stream_->OnStreamHeadersComplete(true, headers.size()); | 165 stream_->OnStreamHeadersComplete(true, headers.size()); |
| 150 EXPECT_EQ(kV3HighestPriority, stream_->priority()); | 166 EXPECT_EQ(kV3HighestPriority, stream_->priority()); |
| 151 EXPECT_EQ("", stream_->data()); | 167 EXPECT_EQ("", stream_->data()); |
| 152 EXPECT_EQ(headers, stream_->decompressed_headers()); | 168 EXPECT_EQ(headers, stream_->decompressed_headers()); |
| 153 EXPECT_FALSE(stream_->IsDoneReading()); | 169 EXPECT_FALSE(stream_->IsDoneReading()); |
| 154 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); | 170 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 155 } | 171 } |
| 156 | 172 |
| 173 TEST_P(QuicSpdyStreamTest, ProcessHeaderListWithFin) { |
| 174 Initialize(kShouldProcessData); |
| 175 |
| 176 size_t total_bytes = 0; |
| 177 QuicHeaderList headers; |
| 178 for (auto p : headers_) { |
| 179 headers.OnHeader(p.first, p.second); |
| 180 total_bytes += p.first.size() + p.second.size(); |
| 181 } |
| 182 stream_->OnStreamHeadersPriority(kV3HighestPriority); |
| 183 stream_->OnStreamHeaderList(true, total_bytes, headers); |
| 184 EXPECT_EQ("", stream_->data()); |
| 185 EXPECT_FALSE(stream_->header_list().empty()); |
| 186 EXPECT_FALSE(stream_->IsDoneReading()); |
| 187 EXPECT_TRUE(stream_->HasFinalReceivedByteOffset()); |
| 188 } |
| 189 |
| 157 TEST_P(QuicSpdyStreamTest, ParseHeaderStatusCode) { | 190 TEST_P(QuicSpdyStreamTest, ParseHeaderStatusCode) { |
| 158 // A valid status code should be 3-digit integer. The first digit should be in | 191 // A valid status code should be 3-digit integer. The first digit should be in |
| 159 // the range of [1, 5]. All the others are invalid. | 192 // the range of [1, 5]. All the others are invalid. |
| 160 Initialize(kShouldProcessData); | 193 Initialize(kShouldProcessData); |
| 161 int status_code = 0; | 194 int status_code = 0; |
| 162 | 195 |
| 163 // Valid status code. | 196 // Valid status code. |
| 164 headers_.ReplaceOrAppendHeader(":status", "404"); | 197 headers_.ReplaceOrAppendHeader(":status", "404"); |
| 165 EXPECT_TRUE(stream_->ParseHeaderStatusCode(&headers_, &status_code)); | 198 EXPECT_TRUE(stream_->ParseHeaderStatusCode(&headers_, &status_code)); |
| 166 EXPECT_EQ(404, status_code); | 199 EXPECT_EQ(404, status_code); |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 | 988 |
| 956 // Writing Trailers should fail, as the FIN has already been sent. | 989 // Writing Trailers should fail, as the FIN has already been sent. |
| 957 // populated with the number of body bytes written. | 990 // populated with the number of body bytes written. |
| 958 EXPECT_DFATAL(stream_->WriteTrailers(SpdyHeaderBlock(), nullptr), | 991 EXPECT_DFATAL(stream_->WriteTrailers(SpdyHeaderBlock(), nullptr), |
| 959 "Trailers cannot be sent after a FIN"); | 992 "Trailers cannot be sent after a FIN"); |
| 960 } | 993 } |
| 961 | 994 |
| 962 } // namespace | 995 } // namespace |
| 963 } // namespace test | 996 } // namespace test |
| 964 } // namespace net | 997 } // namespace net |
| OLD | NEW |