[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/quic/quic_data_stream.h" |
| 6 | |
| 7 | #include "net/quic/quic_ack_notifier.h" |
| 8 | #include "net/quic/quic_connection.h" |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 9 | #include "net/quic/quic_flags.h" |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 10 | #include "net/quic/quic_utils.h" |
[email protected] | 9f0dcd4e | 2014-01-16 15:58:14 | [diff] [blame] | 11 | #include "net/quic/quic_write_blocked_list.h" |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 12 | #include "net/quic/spdy_utils.h" |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 13 | #include "net/quic/test_tools/quic_flow_controller_peer.h" |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 14 | #include "net/quic/test_tools/quic_session_peer.h" |
| 15 | #include "net/quic/test_tools/quic_test_utils.h" |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 16 | #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| 17 | #include "net/test/gtest_util.h" |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 18 | #include "testing/gmock/include/gmock/gmock.h" |
| 19 | |
| 20 | using base::StringPiece; |
| 21 | using std::min; |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 22 | using testing::AnyNumber; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 23 | using testing::InSequence; |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 24 | using testing::Return; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 25 | using testing::SaveArg; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 26 | using testing::StrictMock; |
[email protected] | fddd8c8 | 2014-05-22 19:10:18 | [diff] [blame] | 27 | using testing::_; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 28 | |
| 29 | namespace net { |
| 30 | namespace test { |
| 31 | namespace { |
| 32 | |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 33 | const bool kIsServer = true; |
| 34 | const bool kShouldProcessData = true; |
| 35 | |
| 36 | class TestStream : public QuicDataStream { |
| 37 | public: |
| 38 | TestStream(QuicStreamId id, |
| 39 | QuicSession* session, |
| 40 | bool should_process_data) |
| 41 | : QuicDataStream(id, session), |
| 42 | should_process_data_(should_process_data) {} |
| 43 | |
| 44 | virtual uint32 ProcessData(const char* data, uint32 data_len) OVERRIDE { |
| 45 | EXPECT_NE(0u, data_len); |
| 46 | DVLOG(1) << "ProcessData data_len: " << data_len; |
| 47 | data_ += string(data, data_len); |
| 48 | return should_process_data_ ? data_len : 0; |
| 49 | } |
| 50 | |
| 51 | using ReliableQuicStream::WriteOrBufferData; |
| 52 | using ReliableQuicStream::CloseReadSide; |
| 53 | using ReliableQuicStream::CloseWriteSide; |
| 54 | |
| 55 | const string& data() const { return data_; } |
| 56 | |
| 57 | private: |
| 58 | bool should_process_data_; |
| 59 | string data_; |
| 60 | }; |
| 61 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 62 | class QuicDataStreamTest : public ::testing::TestWithParam<QuicVersion> { |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 63 | public: |
| 64 | QuicDataStreamTest() { |
| 65 | headers_[":host"] = "www.google.com"; |
| 66 | headers_[":path"] = "/index.hml"; |
| 67 | headers_[":scheme"] = "https"; |
| 68 | headers_["cookie"] = |
| 69 | "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; " |
| 70 | "__utmc=160408618; " |
| 71 | "GX=DQAAAOEAAACWJYdewdE9rIrW6qw3PtVi2-d729qaa-74KqOsM1NVQblK4VhX" |
| 72 | "hoALMsy6HOdDad2Sz0flUByv7etmo3mLMidGrBoljqO9hSVA40SLqpG_iuKKSHX" |
| 73 | "RW3Np4bq0F0SDGDNsW0DSmTS9ufMRrlpARJDS7qAI6M3bghqJp4eABKZiRqebHT" |
| 74 | "pMU-RXvTI5D5oCF1vYxYofH_l1Kviuiy3oQ1kS1enqWgbhJ2t61_SNdv-1XJIS0" |
| 75 | "O3YeHLmVCs62O6zp89QwakfAWK9d3IDQvVSJzCQsvxvNIvaZFa567MawWlXg0Rh" |
| 76 | "1zFMi5vzcns38-8_Sns; " |
| 77 | "GA=v*2%2Fmem*57968640*47239936%2Fmem*57968640*47114716%2Fno-nm-" |
| 78 | "yj*15%2Fno-cc-yj*5%2Fpc-ch*133685%2Fpc-s-cr*133947%2Fpc-s-t*1339" |
| 79 | "47%2Fno-nm-yj*4%2Fno-cc-yj*1%2Fceft-as*1%2Fceft-nqas*0%2Fad-ra-c" |
| 80 | "v_p%2Fad-nr-cv_p-f*1%2Fad-v-cv_p*859%2Fad-ns-cv_p-f*1%2Ffn-v-ad%" |
| 81 | "2Fpc-t*250%2Fpc-cm*461%2Fpc-s-cr*722%2Fpc-s-t*722%2Fau_p*4" |
| 82 | "SICAID=AJKiYcHdKgxum7KMXG0ei2t1-W4OD1uW-ecNsCqC0wDuAXiDGIcT_HA2o1" |
| 83 | "3Rs1UKCuBAF9g8rWNOFbxt8PSNSHFuIhOo2t6bJAVpCsMU5Laa6lewuTMYI8MzdQP" |
| 84 | "ARHKyW-koxuhMZHUnGBJAM1gJODe0cATO_KGoX4pbbFxxJ5IicRxOrWK_5rU3cdy6" |
| 85 | "edlR9FsEdH6iujMcHkbE5l18ehJDwTWmBKBzVD87naobhMMrF6VvnDGxQVGp9Ir_b" |
| 86 | "Rgj3RWUoPumQVCxtSOBdX0GlJOEcDTNCzQIm9BSfetog_eP_TfYubKudt5eMsXmN6" |
| 87 | "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG" |
| 88 | "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk" |
| 89 | "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn" |
| 90 | "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr" |
| 91 | "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo "; |
| 92 | } |
| 93 | |
| 94 | void Initialize(bool stream_should_process_data) { |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 95 | connection_ = new testing::StrictMock<MockConnection>( |
| 96 | kIsServer, SupportedVersions(GetParam())); |
| 97 | session_.reset(new testing::StrictMock<MockSession>(connection_)); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 98 | stream_.reset(new TestStream(kClientDataStreamId1, session_.get(), |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 99 | stream_should_process_data)); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 100 | stream2_.reset(new TestStream(kClientDataStreamId2, session_.get(), |
| 101 | stream_should_process_data)); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 102 | write_blocked_list_ = |
[email protected] | aa7e4ef | 2014-05-28 03:53:15 | [diff] [blame] | 103 | QuicSessionPeer::GetWriteBlockedStreams(session_.get()); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | protected: |
| 107 | MockConnection* connection_; |
| 108 | scoped_ptr<MockSession> session_; |
| 109 | scoped_ptr<TestStream> stream_; |
| 110 | scoped_ptr<TestStream> stream2_; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 111 | SpdyHeaderBlock headers_; |
[email protected] | 9f0dcd4e | 2014-01-16 15:58:14 | [diff] [blame] | 112 | QuicWriteBlockedList* write_blocked_list_; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 113 | }; |
| 114 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 115 | INSTANTIATE_TEST_CASE_P(Tests, QuicDataStreamTest, |
| 116 | ::testing::ValuesIn(QuicSupportedVersions())); |
| 117 | |
| 118 | TEST_P(QuicDataStreamTest, ProcessHeaders) { |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 119 | Initialize(kShouldProcessData); |
| 120 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 121 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 122 | stream_->OnStreamHeadersPriority(QuicUtils::HighestPriority()); |
| 123 | stream_->OnStreamHeaders(headers); |
| 124 | EXPECT_EQ(headers, stream_->data()); |
| 125 | stream_->OnStreamHeadersComplete(false, headers.size()); |
[email protected] | c05a6d22 | 2013-12-16 19:42:03 | [diff] [blame] | 126 | EXPECT_EQ(QuicUtils::HighestPriority(), stream_->EffectivePriority()); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 127 | EXPECT_EQ(headers, stream_->data()); |
| 128 | EXPECT_FALSE(stream_->IsDoneReading()); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 129 | } |
| 130 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 131 | TEST_P(QuicDataStreamTest, ProcessHeadersAndBody) { |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 132 | Initialize(kShouldProcessData); |
| 133 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 134 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 135 | string body = "this is the body"; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 136 | |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 137 | stream_->OnStreamHeaders(headers); |
| 138 | EXPECT_EQ(headers, stream_->data()); |
| 139 | stream_->OnStreamHeadersComplete(false, headers.size()); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 140 | QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 141 | stream_->OnStreamFrame(frame); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 142 | |
| 143 | EXPECT_EQ(headers + body, stream_->data()); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 144 | } |
| 145 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 146 | TEST_P(QuicDataStreamTest, ProcessHeadersAndBodyFragments) { |
| 147 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 148 | string body = "this is the body"; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 149 | |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 150 | for (size_t fragment_size = 1; fragment_size < body.size(); |
| 151 | ++fragment_size) { |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 152 | Initialize(kShouldProcessData); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 153 | for (size_t offset = 0; offset < headers.size(); |
| 154 | offset += fragment_size) { |
| 155 | size_t remaining_data = headers.size() - offset; |
| 156 | StringPiece fragment(headers.data() + offset, |
| 157 | min(fragment_size, remaining_data)); |
| 158 | stream_->OnStreamHeaders(fragment); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 159 | } |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 160 | stream_->OnStreamHeadersComplete(false, headers.size()); |
| 161 | for (size_t offset = 0; offset < body.size(); offset += fragment_size) { |
| 162 | size_t remaining_data = body.size() - offset; |
| 163 | StringPiece fragment(body.data() + offset, |
| 164 | min(fragment_size, remaining_data)); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 165 | QuicStreamFrame frame(kClientDataStreamId1, false, offset, |
| 166 | MakeIOVector(fragment)); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 167 | stream_->OnStreamFrame(frame); |
| 168 | } |
| 169 | ASSERT_EQ(headers + body, |
| 170 | stream_->data()) << "fragment_size: " << fragment_size; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 171 | } |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 172 | } |
| 173 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 174 | TEST_P(QuicDataStreamTest, ProcessHeadersAndBodyFragmentsSplit) { |
| 175 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
| 176 | string body = "this is the body"; |
| 177 | |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 178 | for (size_t split_point = 1; split_point < body.size() - 1; ++split_point) { |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 179 | Initialize(kShouldProcessData); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 180 | StringPiece headers1(headers.data(), split_point); |
| 181 | stream_->OnStreamHeaders(headers1); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 182 | |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 183 | StringPiece headers2(headers.data() + split_point, |
| 184 | headers.size() - split_point); |
| 185 | stream_->OnStreamHeaders(headers2); |
| 186 | stream_->OnStreamHeadersComplete(false, headers.size()); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 187 | |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 188 | StringPiece fragment1(body.data(), split_point); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 189 | QuicStreamFrame frame1(kClientDataStreamId1, false, 0, |
| 190 | MakeIOVector(fragment1)); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 191 | stream_->OnStreamFrame(frame1); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 192 | |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 193 | StringPiece fragment2(body.data() + split_point, |
| 194 | body.size() - split_point); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 195 | QuicStreamFrame frame2(kClientDataStreamId1, false, split_point, |
| 196 | MakeIOVector(fragment2)); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 197 | stream_->OnStreamFrame(frame2); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 198 | |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 199 | ASSERT_EQ(headers + body, |
| 200 | stream_->data()) << "split_point: " << split_point; |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
| 204 | TEST_P(QuicDataStreamTest, ProcessHeadersAndBodyReadv) { |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 205 | Initialize(!kShouldProcessData); |
| 206 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 207 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 208 | string body = "this is the body"; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 209 | |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 210 | stream_->OnStreamHeaders(headers); |
| 211 | EXPECT_EQ(headers, stream_->data()); |
| 212 | stream_->OnStreamHeadersComplete(false, headers.size()); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 213 | QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 214 | stream_->OnStreamFrame(frame); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 215 | |
| 216 | char buffer[2048]; |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 217 | ASSERT_LT(headers.length() + body.length(), arraysize(buffer)); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 218 | struct iovec vec; |
| 219 | vec.iov_base = buffer; |
| 220 | vec.iov_len = arraysize(buffer); |
| 221 | |
| 222 | size_t bytes_read = stream_->Readv(&vec, 1); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 223 | EXPECT_EQ(headers.length(), bytes_read); |
| 224 | EXPECT_EQ(headers, string(buffer, bytes_read)); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 225 | |
| 226 | bytes_read = stream_->Readv(&vec, 1); |
| 227 | EXPECT_EQ(body.length(), bytes_read); |
| 228 | EXPECT_EQ(body, string(buffer, bytes_read)); |
| 229 | } |
| 230 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 231 | TEST_P(QuicDataStreamTest, ProcessHeadersAndBodyIncrementalReadv) { |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 232 | Initialize(!kShouldProcessData); |
| 233 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 234 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 235 | string body = "this is the body"; |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 236 | stream_->OnStreamHeaders(headers); |
| 237 | EXPECT_EQ(headers, stream_->data()); |
| 238 | stream_->OnStreamHeadersComplete(false, headers.size()); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 239 | QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 240 | stream_->OnStreamFrame(frame); |
| 241 | |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 242 | char buffer[1]; |
| 243 | struct iovec vec; |
| 244 | vec.iov_base = buffer; |
| 245 | vec.iov_len = arraysize(buffer); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 246 | |
| 247 | string data = headers + body; |
| 248 | for (size_t i = 0; i < data.length(); ++i) { |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 249 | size_t bytes_read = stream_->Readv(&vec, 1); |
| 250 | ASSERT_EQ(1u, bytes_read); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 251 | EXPECT_EQ(data.data()[i], buffer[0]); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 252 | } |
| 253 | } |
| 254 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 255 | TEST_P(QuicDataStreamTest, ProcessHeadersUsingReadvWithMultipleIovecs) { |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 256 | Initialize(!kShouldProcessData); |
| 257 | |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 258 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 259 | string body = "this is the body"; |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 260 | stream_->OnStreamHeaders(headers); |
| 261 | EXPECT_EQ(headers, stream_->data()); |
| 262 | stream_->OnStreamHeadersComplete(false, headers.size()); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 263 | QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
[email protected] | 92bf17c | 2014-03-03 21:14:03 | [diff] [blame] | 264 | stream_->OnStreamFrame(frame); |
| 265 | |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 266 | char buffer1[1]; |
| 267 | char buffer2[1]; |
| 268 | struct iovec vec[2]; |
| 269 | vec[0].iov_base = buffer1; |
| 270 | vec[0].iov_len = arraysize(buffer1); |
| 271 | vec[1].iov_base = buffer2; |
| 272 | vec[1].iov_len = arraysize(buffer2); |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 273 | string data = headers + body; |
| 274 | for (size_t i = 0; i < data.length(); i += 2) { |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 275 | size_t bytes_read = stream_->Readv(vec, 2); |
| 276 | ASSERT_EQ(2u, bytes_read) << i; |
[email protected] | 4d64079 | 2013-12-18 22:21:08 | [diff] [blame] | 277 | ASSERT_EQ(data.data()[i], buffer1[0]) << i; |
| 278 | ASSERT_EQ(data.data()[i + 1], buffer2[0]) << i; |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 282 | TEST_P(QuicDataStreamTest, StreamFlowControlBlocked) { |
| 283 | // Tests that we send a BLOCKED frame to the peer when we attempt to write, |
| 284 | // but are flow control blocked. |
| 285 | if (GetParam() < QUIC_VERSION_17) { |
| 286 | return; |
| 287 | } |
[email protected] | 08da9adb | 2014-04-24 08:33:31 | [diff] [blame] | 288 | ValueRestore<bool> old_flag(&FLAGS_enable_quic_stream_flow_control_2, true); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 289 | |
| 290 | Initialize(kShouldProcessData); |
| 291 | |
| 292 | // Set a small flow control limit. |
| 293 | const uint64 kWindow = 36; |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 294 | QuicFlowControllerPeer::SetSendWindowOffset(stream_->flow_controller(), |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 295 | kWindow); |
| 296 | EXPECT_EQ(kWindow, QuicFlowControllerPeer::SendWindowOffset( |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 297 | stream_->flow_controller())); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 298 | |
| 299 | // Try to send more data than the flow control limit allows. |
| 300 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
| 301 | string body; |
| 302 | const uint64 kOverflow = 15; |
| 303 | GenerateBody(&body, kWindow + kOverflow); |
| 304 | |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 305 | EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)); |
[email protected] | bbb1007 | 2014-06-13 07:41:59 | [diff] [blame^] | 306 | EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _)) |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 307 | .WillOnce(Return(QuicConsumedData(kWindow, true))); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 308 | stream_->WriteOrBufferData(body, false, NULL); |
| 309 | |
| 310 | // Should have sent as much as possible, resulting in no send window left. |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 311 | EXPECT_EQ(0u, |
| 312 | QuicFlowControllerPeer::SendWindowSize(stream_->flow_controller())); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 313 | |
| 314 | // And we should have queued the overflowed data. |
| 315 | EXPECT_EQ(kOverflow, |
| 316 | ReliableQuicStreamPeer::SizeOfQueuedData(stream_.get())); |
| 317 | } |
| 318 | |
| 319 | TEST_P(QuicDataStreamTest, StreamFlowControlNoWindowUpdateIfNotConsumed) { |
| 320 | // The flow control receive window decreases whenever we add new bytes to the |
| 321 | // sequencer, whether they are consumed immediately or buffered. However we |
| 322 | // only send WINDOW_UPDATE frames based on increasing number of bytes |
| 323 | // consumed. |
| 324 | if (GetParam() < QUIC_VERSION_17) { |
| 325 | return; |
| 326 | } |
[email protected] | 08da9adb | 2014-04-24 08:33:31 | [diff] [blame] | 327 | ValueRestore<bool> old_flag(&FLAGS_enable_quic_stream_flow_control_2, true); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 328 | |
| 329 | // Don't process data - it will be buffered instead. |
| 330 | Initialize(!kShouldProcessData); |
| 331 | |
| 332 | // Expect no WINDOW_UPDATE frames to be sent. |
| 333 | EXPECT_CALL(*connection_, SendWindowUpdate(_, _)).Times(0); |
| 334 | |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 335 | // Set a small flow control receive window. |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 336 | const uint64 kWindow = 36; |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 337 | QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), |
| 338 | kWindow); |
| 339 | QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(), |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 340 | kWindow); |
| 341 | EXPECT_EQ(kWindow, QuicFlowControllerPeer::ReceiveWindowOffset( |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 342 | stream_->flow_controller())); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 343 | |
| 344 | // Stream receives enough data to fill a fraction of the receive window. |
| 345 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
| 346 | string body; |
| 347 | GenerateBody(&body, kWindow / 3); |
| 348 | stream_->OnStreamHeaders(headers); |
| 349 | EXPECT_EQ(headers, stream_->data()); |
| 350 | stream_->OnStreamHeadersComplete(false, headers.size()); |
| 351 | |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 352 | QuicStreamFrame frame1(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 353 | stream_->OnStreamFrame(frame1); |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 354 | EXPECT_EQ(kWindow - (kWindow / 3), QuicFlowControllerPeer::ReceiveWindowSize( |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 355 | stream_->flow_controller())); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 356 | |
| 357 | // Now receive another frame which results in the receive window being over |
| 358 | // half full. This should all be buffered, decreasing the receive window but |
| 359 | // not sending WINDOW_UPDATE. |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 360 | QuicStreamFrame frame2(kClientDataStreamId1, false, kWindow / 3, |
| 361 | MakeIOVector(body)); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 362 | stream_->OnStreamFrame(frame2); |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 363 | EXPECT_EQ( |
| 364 | kWindow - (2 * kWindow / 3), |
| 365 | QuicFlowControllerPeer::ReceiveWindowSize(stream_->flow_controller())); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | TEST_P(QuicDataStreamTest, StreamFlowControlWindowUpdate) { |
| 369 | // Tests that on receipt of data, the stream updates its receive window offset |
| 370 | // appropriately, and sends WINDOW_UPDATE frames when its receive window drops |
| 371 | // too low. |
| 372 | if (GetParam() < QUIC_VERSION_17) { |
| 373 | return; |
| 374 | } |
[email protected] | 08da9adb | 2014-04-24 08:33:31 | [diff] [blame] | 375 | ValueRestore<bool> old_flag(&FLAGS_enable_quic_stream_flow_control_2, true); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 376 | |
| 377 | Initialize(kShouldProcessData); |
| 378 | |
| 379 | // Set a small flow control limit. |
| 380 | const uint64 kWindow = 36; |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 381 | QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), |
| 382 | kWindow); |
| 383 | QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(), |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 384 | kWindow); |
| 385 | EXPECT_EQ(kWindow, QuicFlowControllerPeer::ReceiveWindowOffset( |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 386 | stream_->flow_controller())); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 387 | |
| 388 | // Stream receives enough data to fill a fraction of the receive window. |
| 389 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
| 390 | string body; |
| 391 | GenerateBody(&body, kWindow / 3); |
| 392 | stream_->OnStreamHeaders(headers); |
| 393 | EXPECT_EQ(headers, stream_->data()); |
| 394 | stream_->OnStreamHeadersComplete(false, headers.size()); |
| 395 | |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 396 | QuicStreamFrame frame1(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 397 | stream_->OnStreamFrame(frame1); |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 398 | EXPECT_EQ(kWindow - (kWindow / 3), QuicFlowControllerPeer::ReceiveWindowSize( |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 399 | stream_->flow_controller())); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 400 | |
| 401 | // Now receive another frame which results in the receive window being over |
| 402 | // half full. This will trigger the stream to increase its receive window |
| 403 | // offset and send a WINDOW_UPDATE. The result will be again an available |
| 404 | // window of kWindow bytes. |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 405 | QuicStreamFrame frame2(kClientDataStreamId1, false, kWindow / 3, |
| 406 | MakeIOVector(body)); |
| 407 | EXPECT_CALL(*connection_, |
| 408 | SendWindowUpdate(kClientDataStreamId1, |
| 409 | QuicFlowControllerPeer::ReceiveWindowOffset( |
| 410 | stream_->flow_controller()) + |
| 411 | 2 * kWindow / 3)); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 412 | stream_->OnStreamFrame(frame2); |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 413 | EXPECT_EQ(kWindow, QuicFlowControllerPeer::ReceiveWindowSize( |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 414 | stream_->flow_controller())); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 415 | } |
| 416 | |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 417 | TEST_P(QuicDataStreamTest, ConnectionFlowControlWindowUpdate) { |
| 418 | // Tests that on receipt of data, the connection updates its receive window |
| 419 | // offset appropriately, and sends WINDOW_UPDATE frames when its receive |
| 420 | // window drops too low. |
| 421 | if (GetParam() < QUIC_VERSION_19) { |
| 422 | return; |
| 423 | } |
| 424 | ValueRestore<bool> old_flag2(&FLAGS_enable_quic_stream_flow_control_2, true); |
| 425 | ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); |
| 426 | |
| 427 | Initialize(kShouldProcessData); |
| 428 | |
| 429 | // Set a small flow control limit for streams and connection. |
| 430 | const uint64 kWindow = 36; |
| 431 | QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), |
| 432 | kWindow); |
| 433 | QuicFlowControllerPeer::SetMaxReceiveWindow(stream_->flow_controller(), |
| 434 | kWindow); |
| 435 | QuicFlowControllerPeer::SetReceiveWindowOffset(stream2_->flow_controller(), |
| 436 | kWindow); |
| 437 | QuicFlowControllerPeer::SetMaxReceiveWindow(stream2_->flow_controller(), |
| 438 | kWindow); |
[email protected] | ce7bb141 | 2014-05-17 15:51:33 | [diff] [blame] | 439 | QuicFlowControllerPeer::SetReceiveWindowOffset(session_->flow_controller(), |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 440 | kWindow); |
[email protected] | ce7bb141 | 2014-05-17 15:51:33 | [diff] [blame] | 441 | QuicFlowControllerPeer::SetMaxReceiveWindow(session_->flow_controller(), |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 442 | kWindow); |
| 443 | |
| 444 | // Supply headers to both streams so that they are happy to receive data. |
| 445 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
| 446 | stream_->OnStreamHeaders(headers); |
| 447 | stream_->OnStreamHeadersComplete(false, headers.size()); |
| 448 | stream2_->OnStreamHeaders(headers); |
| 449 | stream2_->OnStreamHeadersComplete(false, headers.size()); |
| 450 | |
| 451 | // Each stream gets a quarter window of data. This should not trigger a |
| 452 | // WINDOW_UPDATE for either stream, nor for the connection. |
| 453 | string body; |
| 454 | GenerateBody(&body, kWindow / 4); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 455 | QuicStreamFrame frame1(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 456 | stream_->OnStreamFrame(frame1); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 457 | QuicStreamFrame frame2(kClientDataStreamId2, false, 0, MakeIOVector(body)); |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 458 | stream2_->OnStreamFrame(frame2); |
| 459 | |
| 460 | // Now receive a further single byte on one stream - again this does not |
| 461 | // trigger a stream WINDOW_UPDATE, but now the connection flow control window |
| 462 | // is over half full and thus a connection WINDOW_UPDATE is sent. |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 463 | EXPECT_CALL(*connection_, SendWindowUpdate(kClientDataStreamId1, _)).Times(0); |
| 464 | EXPECT_CALL(*connection_, SendWindowUpdate(kClientDataStreamId2, _)).Times(0); |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 465 | EXPECT_CALL(*connection_, |
| 466 | SendWindowUpdate(0, QuicFlowControllerPeer::ReceiveWindowOffset( |
[email protected] | ce7bb141 | 2014-05-17 15:51:33 | [diff] [blame] | 467 | session_->flow_controller()) + |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 468 | 1 + kWindow / 2)); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 469 | QuicStreamFrame frame3(kClientDataStreamId1, false, (kWindow / 4), |
| 470 | MakeIOVector("a")); |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 471 | stream_->OnStreamFrame(frame3); |
| 472 | } |
| 473 | |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 474 | TEST_P(QuicDataStreamTest, StreamFlowControlViolation) { |
| 475 | // Tests that on if the peer sends too much data (i.e. violates the flow |
| 476 | // control protocol), then we terminate the connection. |
| 477 | if (GetParam() < QUIC_VERSION_17) { |
| 478 | return; |
| 479 | } |
[email protected] | 08da9adb | 2014-04-24 08:33:31 | [diff] [blame] | 480 | ValueRestore<bool> old_flag(&FLAGS_enable_quic_stream_flow_control_2, true); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 481 | |
| 482 | // Stream should not process data, so that data gets buffered in the |
| 483 | // sequencer, triggering flow control limits. |
| 484 | Initialize(!kShouldProcessData); |
| 485 | |
| 486 | // Set a small flow control limit. |
| 487 | const uint64 kWindow = 50; |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 488 | QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), |
| 489 | kWindow); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 490 | |
| 491 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 492 | stream_->OnStreamHeaders(headers); |
| 493 | EXPECT_EQ(headers, stream_->data()); |
| 494 | stream_->OnStreamHeadersComplete(false, headers.size()); |
| 495 | |
| 496 | // Receive data to overflow the window, violating flow control. |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 497 | string body; |
| 498 | GenerateBody(&body, kWindow + 1); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 499 | QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 500 | EXPECT_CALL(*connection_, |
| 501 | SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); |
[email protected] | d8c52211 | 2014-04-23 09:23:25 | [diff] [blame] | 502 | stream_->OnStreamFrame(frame); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 503 | } |
| 504 | |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 505 | TEST_P(QuicDataStreamTest, ConnectionFlowControlViolation) { |
| 506 | // Tests that on if the peer sends too much data (i.e. violates the flow |
| 507 | // control protocol), at the connection level (rather than the stream level) |
| 508 | // then we terminate the connection. |
| 509 | if (GetParam() < QUIC_VERSION_19) { |
| 510 | return; |
| 511 | } |
| 512 | ValueRestore<bool> old_flag2(&FLAGS_enable_quic_stream_flow_control_2, true); |
| 513 | ValueRestore<bool> old_flag(&FLAGS_enable_quic_connection_flow_control, true); |
| 514 | |
| 515 | // Stream should not process data, so that data gets buffered in the |
| 516 | // sequencer, triggering flow control limits. |
| 517 | Initialize(!kShouldProcessData); |
| 518 | |
| 519 | // Set a small flow control window on streams, and connection. |
| 520 | const uint64 kStreamWindow = 50; |
| 521 | const uint64 kConnectionWindow = 10; |
| 522 | QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), |
| 523 | kStreamWindow); |
[email protected] | ce7bb141 | 2014-05-17 15:51:33 | [diff] [blame] | 524 | QuicFlowControllerPeer::SetReceiveWindowOffset(session_->flow_controller(), |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 525 | kConnectionWindow); |
| 526 | |
| 527 | string headers = SpdyUtils::SerializeUncompressedHeaders(headers_); |
| 528 | stream_->OnStreamHeaders(headers); |
| 529 | EXPECT_EQ(headers, stream_->data()); |
| 530 | stream_->OnStreamHeadersComplete(false, headers.size()); |
| 531 | |
| 532 | // Send enough data to overflow the connection level flow control window. |
| 533 | string body; |
| 534 | GenerateBody(&body, kConnectionWindow + 1); |
| 535 | EXPECT_LT(body.size(), kStreamWindow); |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 536 | QuicStreamFrame frame(kClientDataStreamId1, false, 0, MakeIOVector(body)); |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 537 | |
[email protected] | 730b35d7 | 2014-06-05 03:23:22 | [diff] [blame] | 538 | EXPECT_CALL(*connection_, |
| 539 | SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA)); |
[email protected] | 77b5d50b | 2014-05-07 22:48:48 | [diff] [blame] | 540 | stream_->OnStreamFrame(frame); |
| 541 | } |
| 542 | |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 543 | TEST_P(QuicDataStreamTest, StreamFlowControlFinNotBlocked) { |
| 544 | // An attempt to write a FIN with no data should not be flow control blocked, |
| 545 | // even if the send window is 0. |
| 546 | if (GetParam() < QUIC_VERSION_17) { |
| 547 | return; |
| 548 | } |
[email protected] | 08da9adb | 2014-04-24 08:33:31 | [diff] [blame] | 549 | ValueRestore<bool> old_flag(&FLAGS_enable_quic_stream_flow_control_2, true); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 550 | |
| 551 | Initialize(kShouldProcessData); |
| 552 | |
| 553 | // Set a flow control limit of zero. |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 554 | QuicFlowControllerPeer::SetReceiveWindowOffset(stream_->flow_controller(), 0); |
[email protected] | 51cc134 | 2014-04-18 23:44:37 | [diff] [blame] | 555 | EXPECT_EQ(0u, QuicFlowControllerPeer::ReceiveWindowOffset( |
[email protected] | 82168ee2 | 2014-04-30 22:25:48 | [diff] [blame] | 556 | stream_->flow_controller())); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 557 | |
| 558 | // Send a frame with a FIN but no data. This should not be blocked. |
| 559 | string body = ""; |
| 560 | bool fin = true; |
| 561 | |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 562 | EXPECT_CALL(*connection_, SendBlocked(kClientDataStreamId1)).Times(0); |
[email protected] | bbb1007 | 2014-06-13 07:41:59 | [diff] [blame^] | 563 | EXPECT_CALL(*session_, WritevData(kClientDataStreamId1, _, _, _, _, _)) |
[email protected] | 66ae596 | 2014-05-22 11:13:05 | [diff] [blame] | 564 | .WillOnce(Return(QuicConsumedData(0, fin))); |
[email protected] | 9bb57c7 | 2014-03-31 20:36:04 | [diff] [blame] | 565 | |
| 566 | stream_->WriteOrBufferData(body, fin, NULL); |
| 567 | } |
| 568 | |
[email protected] | 457d695 | 2013-12-13 09:24:58 | [diff] [blame] | 569 | } // namespace |
| 570 | } // namespace test |
| 571 | } // namespace net |