Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / net / quic / quic_session_test.cc
blobe37e7c2f214c84bb95f5d351863e3922435f37c6
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
3 // found in the LICENSE file.
5 #include "net/quic/quic_session.h"
7 #include <set>
9 #include "base/basictypes.h"
10 #include "base/containers/hash_tables.h"
11 #include "base/rand_util.h"
12 #include "base/stl_util.h"
13 #include "base/strings/string_number_conversions.h"
14 #include "net/quic/crypto/crypto_protocol.h"
15 #include "net/quic/quic_crypto_stream.h"
16 #include "net/quic/quic_flags.h"
17 #include "net/quic/quic_protocol.h"
18 #include "net/quic/quic_utils.h"
19 #include "net/quic/reliable_quic_stream.h"
20 #include "net/quic/test_tools/quic_config_peer.h"
21 #include "net/quic/test_tools/quic_connection_peer.h"
22 #include "net/quic/test_tools/quic_data_stream_peer.h"
23 #include "net/quic/test_tools/quic_flow_controller_peer.h"
24 #include "net/quic/test_tools/quic_session_peer.h"
25 #include "net/quic/test_tools/quic_test_utils.h"
26 #include "net/quic/test_tools/reliable_quic_stream_peer.h"
27 #include "net/spdy/spdy_framer.h"
28 #include "net/test/gtest_util.h"
29 #include "testing/gmock/include/gmock/gmock.h"
30 #include "testing/gmock_mutant.h"
31 #include "testing/gtest/include/gtest/gtest.h"
33 using base::hash_map;
34 using std::set;
35 using std::string;
36 using std::vector;
37 using testing::CreateFunctor;
38 using testing::InSequence;
39 using testing::Invoke;
40 using testing::Return;
41 using testing::StrictMock;
42 using testing::_;
44 namespace net {
45 namespace test {
46 namespace {
48 const QuicPriority kHighestPriority = 0;
49 const QuicPriority kSomeMiddlePriority = 3;
51 class TestCryptoStream : public QuicCryptoStream {
52 public:
53 explicit TestCryptoStream(QuicSession* session)
54 : QuicCryptoStream(session) {
57 void OnHandshakeMessage(const CryptoHandshakeMessage& message) override {
58 encryption_established_ = true;
59 handshake_confirmed_ = true;
60 CryptoHandshakeMessage msg;
61 string error_details;
62 session()->config()->SetInitialStreamFlowControlWindowToSend(
63 kInitialStreamFlowControlWindowForTest);
64 session()->config()->SetInitialSessionFlowControlWindowToSend(
65 kInitialSessionFlowControlWindowForTest);
66 session()->config()->ToHandshakeMessage(&msg);
67 const QuicErrorCode error = session()->config()->ProcessPeerHello(
68 msg, CLIENT, &error_details);
69 EXPECT_EQ(QUIC_NO_ERROR, error);
70 session()->OnConfigNegotiated();
71 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
74 MOCK_METHOD0(OnCanWrite, void());
77 class TestHeadersStream : public QuicHeadersStream {
78 public:
79 explicit TestHeadersStream(QuicSession* session)
80 : QuicHeadersStream(session) {
83 MOCK_METHOD0(OnCanWrite, void());
86 class TestStream : public QuicDataStream {
87 public:
88 TestStream(QuicStreamId id, QuicSession* session)
89 : QuicDataStream(id, session) {
92 using ReliableQuicStream::CloseWriteSide;
94 uint32 ProcessData(const char* data, uint32 data_len) override {
95 return data_len;
98 void SendBody(const string& data, bool fin) {
99 WriteOrBufferData(data, fin, nullptr);
102 MOCK_METHOD0(OnCanWrite, void());
105 // Poor man's functor for use as callback in a mock.
106 class StreamBlocker {
107 public:
108 StreamBlocker(QuicSession* session, QuicStreamId stream_id)
109 : session_(session),
110 stream_id_(stream_id) {
113 void MarkWriteBlocked() {
114 session_->MarkWriteBlocked(stream_id_, kSomeMiddlePriority);
117 private:
118 QuicSession* const session_;
119 const QuicStreamId stream_id_;
122 class TestSession : public QuicSession {
123 public:
124 explicit TestSession(QuicConnection* connection)
125 : QuicSession(connection, DefaultQuicConfig()),
126 crypto_stream_(this),
127 writev_consumes_all_data_(false) {
128 InitializeSession();
131 TestCryptoStream* GetCryptoStream() override { return &crypto_stream_; }
133 TestStream* CreateOutgoingDataStream() override {
134 TestStream* stream = new TestStream(GetNextStreamId(), this);
135 ActivateStream(stream);
136 return stream;
139 TestStream* CreateIncomingDataStream(QuicStreamId id) override {
140 return new TestStream(id, this);
143 bool IsClosedStream(QuicStreamId id) {
144 return QuicSession::IsClosedStream(id);
147 QuicDataStream* GetIncomingDataStream(QuicStreamId stream_id) {
148 return QuicSession::GetIncomingDataStream(stream_id);
151 QuicConsumedData WritevData(
152 QuicStreamId id,
153 const IOVector& data,
154 QuicStreamOffset offset,
155 bool fin,
156 FecProtection fec_protection,
157 QuicAckNotifier::DelegateInterface* ack_notifier_delegate) override {
158 // Always consumes everything.
159 if (writev_consumes_all_data_) {
160 return QuicConsumedData(data.TotalBufferSize(), fin);
161 } else {
162 return QuicSession::WritevData(id, data, offset, fin, fec_protection,
163 ack_notifier_delegate);
167 void set_writev_consumes_all_data(bool val) {
168 writev_consumes_all_data_ = val;
171 QuicConsumedData SendStreamData(QuicStreamId id) {
172 return WritevData(id, MakeIOVector("not empty"), 0, true, MAY_FEC_PROTECT,
173 nullptr);
176 using QuicSession::PostProcessAfterData;
178 private:
179 StrictMock<TestCryptoStream> crypto_stream_;
181 bool writev_consumes_all_data_;
184 class QuicSessionTest : public ::testing::TestWithParam<QuicVersion> {
185 protected:
186 QuicSessionTest()
187 : connection_(
188 new StrictMock<MockConnection>(Perspective::IS_SERVER,
189 SupportedVersions(GetParam()))),
190 session_(connection_) {
191 session_.config()->SetInitialStreamFlowControlWindowToSend(
192 kInitialStreamFlowControlWindowForTest);
193 session_.config()->SetInitialSessionFlowControlWindowToSend(
194 kInitialSessionFlowControlWindowForTest);
195 headers_[":host"] = "www.google.com";
196 headers_[":path"] = "/index.hml";
197 headers_[":scheme"] = "http";
198 headers_["cookie"] =
199 "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; "
200 "__utmc=160408618; "
201 "GX=DQAAAOEAAACWJYdewdE9rIrW6qw3PtVi2-d729qaa-74KqOsM1NVQblK4VhX"
202 "hoALMsy6HOdDad2Sz0flUByv7etmo3mLMidGrBoljqO9hSVA40SLqpG_iuKKSHX"
203 "RW3Np4bq0F0SDGDNsW0DSmTS9ufMRrlpARJDS7qAI6M3bghqJp4eABKZiRqebHT"
204 "pMU-RXvTI5D5oCF1vYxYofH_l1Kviuiy3oQ1kS1enqWgbhJ2t61_SNdv-1XJIS0"
205 "O3YeHLmVCs62O6zp89QwakfAWK9d3IDQvVSJzCQsvxvNIvaZFa567MawWlXg0Rh"
206 "1zFMi5vzcns38-8_Sns; "
207 "GA=v*2%2Fmem*57968640*47239936%2Fmem*57968640*47114716%2Fno-nm-"
208 "yj*15%2Fno-cc-yj*5%2Fpc-ch*133685%2Fpc-s-cr*133947%2Fpc-s-t*1339"
209 "47%2Fno-nm-yj*4%2Fno-cc-yj*1%2Fceft-as*1%2Fceft-nqas*0%2Fad-ra-c"
210 "v_p%2Fad-nr-cv_p-f*1%2Fad-v-cv_p*859%2Fad-ns-cv_p-f*1%2Ffn-v-ad%"
211 "2Fpc-t*250%2Fpc-cm*461%2Fpc-s-cr*722%2Fpc-s-t*722%2Fau_p*4"
212 "SICAID=AJKiYcHdKgxum7KMXG0ei2t1-W4OD1uW-ecNsCqC0wDuAXiDGIcT_HA2o1"
213 "3Rs1UKCuBAF9g8rWNOFbxt8PSNSHFuIhOo2t6bJAVpCsMU5Laa6lewuTMYI8MzdQP"
214 "ARHKyW-koxuhMZHUnGBJAM1gJODe0cATO_KGoX4pbbFxxJ5IicRxOrWK_5rU3cdy6"
215 "edlR9FsEdH6iujMcHkbE5l18ehJDwTWmBKBzVD87naobhMMrF6VvnDGxQVGp9Ir_b"
216 "Rgj3RWUoPumQVCxtSOBdX0GlJOEcDTNCzQIm9BSfetog_eP_TfYubKudt5eMsXmN6"
217 "QnyXHeGeK2UINUzJ-D30AFcpqYgH9_1BvYSpi7fc7_ydBU8TaD8ZRxvtnzXqj0RfG"
218 "tuHghmv3aD-uzSYJ75XDdzKdizZ86IG6Fbn1XFhYZM-fbHhm3mVEXnyRW4ZuNOLFk"
219 "Fas6LMcVC6Q8QLlHYbXBpdNFuGbuZGUnav5C-2I_-46lL0NGg3GewxGKGHvHEfoyn"
220 "EFFlEYHsBQ98rXImL8ySDycdLEFvBPdtctPmWCfTxwmoSMLHU2SCVDhbqMWU5b0yr"
221 "JBCScs_ejbKaqBDoB7ZGxTvqlrB__2ZmnHHjCr8RgMRtKNtIeuZAo ";
222 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1));
225 void CheckClosedStreams() {
226 for (int i = kCryptoStreamId; i < 100; i++) {
227 if (!ContainsKey(closed_streams_, i)) {
228 EXPECT_FALSE(session_.IsClosedStream(i)) << " stream id: " << i;
229 } else {
230 EXPECT_TRUE(session_.IsClosedStream(i)) << " stream id: " << i;
235 void CloseStream(QuicStreamId id) {
236 EXPECT_CALL(*connection_, SendRstStream(id, _, _));
237 session_.CloseStream(id);
238 closed_streams_.insert(id);
241 QuicVersion version() const { return connection_->version(); }
243 StrictMock<MockConnection>* connection_;
244 TestSession session_;
245 set<QuicStreamId> closed_streams_;
246 SpdyHeaderBlock headers_;
249 INSTANTIATE_TEST_CASE_P(Tests, QuicSessionTest,
250 ::testing::ValuesIn(QuicSupportedVersions()));
252 TEST_P(QuicSessionTest, PeerAddress) {
253 EXPECT_EQ(IPEndPoint(Loopback4(), kTestPort), session_.peer_address());
256 TEST_P(QuicSessionTest, IsCryptoHandshakeConfirmed) {
257 EXPECT_FALSE(session_.IsCryptoHandshakeConfirmed());
258 CryptoHandshakeMessage message;
259 session_.GetCryptoStream()->OnHandshakeMessage(message);
260 EXPECT_TRUE(session_.IsCryptoHandshakeConfirmed());
263 TEST_P(QuicSessionTest, IsClosedStreamDefault) {
264 // Ensure that no streams are initially closed.
265 for (int i = kCryptoStreamId; i < 100; i++) {
266 EXPECT_FALSE(session_.IsClosedStream(i)) << "stream id: " << i;
270 TEST_P(QuicSessionTest, ImplicitlyCreatedStreams) {
271 ASSERT_TRUE(session_.GetIncomingDataStream(7) != nullptr);
272 // Both 3 and 5 should be implicitly created.
273 EXPECT_FALSE(session_.IsClosedStream(3));
274 EXPECT_FALSE(session_.IsClosedStream(5));
275 ASSERT_TRUE(session_.GetIncomingDataStream(5) != nullptr);
276 ASSERT_TRUE(session_.GetIncomingDataStream(3) != nullptr);
279 TEST_P(QuicSessionTest, IsClosedStreamLocallyCreated) {
280 TestStream* stream2 = session_.CreateOutgoingDataStream();
281 EXPECT_EQ(2u, stream2->id());
282 TestStream* stream4 = session_.CreateOutgoingDataStream();
283 EXPECT_EQ(4u, stream4->id());
285 CheckClosedStreams();
286 CloseStream(4);
287 CheckClosedStreams();
288 CloseStream(2);
289 CheckClosedStreams();
292 TEST_P(QuicSessionTest, IsClosedStreamPeerCreated) {
293 QuicStreamId stream_id1 = kClientDataStreamId1;
294 QuicStreamId stream_id2 = kClientDataStreamId2;
295 QuicDataStream* stream1 = session_.GetIncomingDataStream(stream_id1);
296 QuicDataStreamPeer::SetHeadersDecompressed(stream1, true);
297 QuicDataStream* stream2 = session_.GetIncomingDataStream(stream_id2);
298 QuicDataStreamPeer::SetHeadersDecompressed(stream2, true);
300 CheckClosedStreams();
301 CloseStream(stream_id1);
302 CheckClosedStreams();
303 CloseStream(stream_id2);
304 // Create a stream explicitly, and another implicitly.
305 QuicDataStream* stream3 = session_.GetIncomingDataStream(stream_id2 + 4);
306 QuicDataStreamPeer::SetHeadersDecompressed(stream3, true);
307 CheckClosedStreams();
308 // Close one, but make sure the other is still not closed
309 CloseStream(stream3->id());
310 CheckClosedStreams();
313 TEST_P(QuicSessionTest, StreamIdTooLarge) {
314 QuicStreamId stream_id = kClientDataStreamId1;
315 session_.GetIncomingDataStream(stream_id);
316 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID));
317 session_.GetIncomingDataStream(stream_id + kMaxStreamIdDelta + 2);
320 TEST_P(QuicSessionTest, DecompressionError) {
321 QuicHeadersStream* stream = QuicSessionPeer::GetHeadersStream(&session_);
322 if (version() > QUIC_VERSION_23) {
323 // This test does not apply to HPACK compression.
324 return;
326 const unsigned char data[] = {
327 0x80, 0x03, 0x00, 0x01, // SPDY/3 SYN_STREAM frame
328 0x00, 0x00, 0x00, 0x25, // flags/length
329 0x00, 0x00, 0x00, 0x05, // stream id
330 0x00, 0x00, 0x00, 0x00, // associated stream id
331 0x00, 0x00,
332 'a', 'b', 'c', 'd' // invalid compressed data
334 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(
335 QUIC_INVALID_HEADERS_STREAM_DATA,
336 "SPDY framing error: DECOMPRESS_FAILURE"));
337 stream->ProcessRawData(reinterpret_cast<const char*>(data),
338 arraysize(data));
341 TEST_P(QuicSessionTest, DebugDFatalIfMarkingClosedStreamWriteBlocked) {
342 TestStream* stream2 = session_.CreateOutgoingDataStream();
343 QuicStreamId kClosedStreamId = stream2->id();
344 // Close the stream.
345 EXPECT_CALL(*connection_, SendRstStream(kClosedStreamId, _, _));
346 stream2->Reset(QUIC_BAD_APPLICATION_PAYLOAD);
347 EXPECT_DEBUG_DFATAL(
348 session_.MarkWriteBlocked(kClosedStreamId, kSomeMiddlePriority),
349 "Marking unknown stream 2 blocked.");
352 TEST_P(QuicSessionTest, DebugDFatalIfMarkWriteBlockedCalledWithWrongPriority) {
353 const QuicPriority kDifferentPriority = 0;
355 TestStream* stream2 = session_.CreateOutgoingDataStream();
356 EXPECT_NE(kDifferentPriority, stream2->EffectivePriority());
357 EXPECT_DEBUG_DFATAL(
358 session_.MarkWriteBlocked(stream2->id(), kDifferentPriority),
359 "Priorities do not match. Got: 0 Expected: 3");
362 TEST_P(QuicSessionTest, OnCanWrite) {
363 TestStream* stream2 = session_.CreateOutgoingDataStream();
364 TestStream* stream4 = session_.CreateOutgoingDataStream();
365 TestStream* stream6 = session_.CreateOutgoingDataStream();
367 session_.MarkWriteBlocked(stream2->id(), kSomeMiddlePriority);
368 session_.MarkWriteBlocked(stream6->id(), kSomeMiddlePriority);
369 session_.MarkWriteBlocked(stream4->id(), kSomeMiddlePriority);
371 InSequence s;
372 StreamBlocker stream2_blocker(&session_, stream2->id());
373 // Reregister, to test the loop limit.
374 EXPECT_CALL(*stream2, OnCanWrite())
375 .WillOnce(Invoke(&stream2_blocker, &StreamBlocker::MarkWriteBlocked));
376 EXPECT_CALL(*stream6, OnCanWrite());
377 EXPECT_CALL(*stream4, OnCanWrite());
378 session_.OnCanWrite();
379 EXPECT_TRUE(session_.WillingAndAbleToWrite());
382 TEST_P(QuicSessionTest, OnCanWriteBundlesStreams) {
383 // Drive congestion control manually.
384 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
385 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), send_algorithm);
387 TestStream* stream2 = session_.CreateOutgoingDataStream();
388 TestStream* stream4 = session_.CreateOutgoingDataStream();
389 TestStream* stream6 = session_.CreateOutgoingDataStream();
391 session_.MarkWriteBlocked(stream2->id(), kSomeMiddlePriority);
392 session_.MarkWriteBlocked(stream6->id(), kSomeMiddlePriority);
393 session_.MarkWriteBlocked(stream4->id(), kSomeMiddlePriority);
395 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)).WillRepeatedly(
396 Return(QuicTime::Delta::Zero()));
397 EXPECT_CALL(*send_algorithm, GetCongestionWindow())
398 .WillRepeatedly(Return(kMaxPacketSize * 10));
399 EXPECT_CALL(*stream2, OnCanWrite())
400 .WillOnce(IgnoreResult(Invoke(CreateFunctor(
401 &session_, &TestSession::SendStreamData, stream2->id()))));
402 EXPECT_CALL(*stream4, OnCanWrite())
403 .WillOnce(IgnoreResult(Invoke(CreateFunctor(
404 &session_, &TestSession::SendStreamData, stream4->id()))));
405 EXPECT_CALL(*stream6, OnCanWrite())
406 .WillOnce(IgnoreResult(Invoke(CreateFunctor(
407 &session_, &TestSession::SendStreamData, stream6->id()))));
409 // Expect that we only send one packet, the writes from different streams
410 // should be bundled together.
411 MockPacketWriter* writer =
412 static_cast<MockPacketWriter*>(
413 QuicConnectionPeer::GetWriter(session_.connection()));
414 EXPECT_CALL(*writer, WritePacket(_, _, _, _)).WillOnce(
415 Return(WriteResult(WRITE_STATUS_OK, 0)));
416 EXPECT_CALL(*send_algorithm, OnPacketSent(_, _, _, _, _)).Times(1);
417 session_.OnCanWrite();
418 EXPECT_FALSE(session_.WillingAndAbleToWrite());
421 TEST_P(QuicSessionTest, OnCanWriteCongestionControlBlocks) {
422 InSequence s;
424 // Drive congestion control manually.
425 MockSendAlgorithm* send_algorithm = new StrictMock<MockSendAlgorithm>;
426 QuicConnectionPeer::SetSendAlgorithm(session_.connection(), send_algorithm);
428 TestStream* stream2 = session_.CreateOutgoingDataStream();
429 TestStream* stream4 = session_.CreateOutgoingDataStream();
430 TestStream* stream6 = session_.CreateOutgoingDataStream();
432 session_.MarkWriteBlocked(stream2->id(), kSomeMiddlePriority);
433 session_.MarkWriteBlocked(stream6->id(), kSomeMiddlePriority);
434 session_.MarkWriteBlocked(stream4->id(), kSomeMiddlePriority);
436 StreamBlocker stream2_blocker(&session_, stream2->id());
437 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)).WillOnce(Return(
438 QuicTime::Delta::Zero()));
439 EXPECT_CALL(*stream2, OnCanWrite());
440 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)).WillOnce(Return(
441 QuicTime::Delta::Zero()));
442 EXPECT_CALL(*stream6, OnCanWrite());
443 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)).WillOnce(Return(
444 QuicTime::Delta::Infinite()));
445 // stream4->OnCanWrite is not called.
447 session_.OnCanWrite();
448 EXPECT_TRUE(session_.WillingAndAbleToWrite());
450 // Still congestion-control blocked.
451 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)).WillOnce(Return(
452 QuicTime::Delta::Infinite()));
453 session_.OnCanWrite();
454 EXPECT_TRUE(session_.WillingAndAbleToWrite());
456 // stream4->OnCanWrite is called once the connection stops being
457 // congestion-control blocked.
458 EXPECT_CALL(*send_algorithm, TimeUntilSend(_, _, _)).WillOnce(Return(
459 QuicTime::Delta::Zero()));
460 EXPECT_CALL(*stream4, OnCanWrite());
461 session_.OnCanWrite();
462 EXPECT_FALSE(session_.WillingAndAbleToWrite());
465 TEST_P(QuicSessionTest, BufferedHandshake) {
466 EXPECT_FALSE(session_.HasPendingHandshake()); // Default value.
468 // Test that blocking other streams does not change our status.
469 TestStream* stream2 = session_.CreateOutgoingDataStream();
470 StreamBlocker stream2_blocker(&session_, stream2->id());
471 stream2_blocker.MarkWriteBlocked();
472 EXPECT_FALSE(session_.HasPendingHandshake());
474 TestStream* stream3 = session_.CreateOutgoingDataStream();
475 StreamBlocker stream3_blocker(&session_, stream3->id());
476 stream3_blocker.MarkWriteBlocked();
477 EXPECT_FALSE(session_.HasPendingHandshake());
479 // Blocking (due to buffering of) the Crypto stream is detected.
480 session_.MarkWriteBlocked(kCryptoStreamId, kHighestPriority);
481 EXPECT_TRUE(session_.HasPendingHandshake());
483 TestStream* stream4 = session_.CreateOutgoingDataStream();
484 StreamBlocker stream4_blocker(&session_, stream4->id());
485 stream4_blocker.MarkWriteBlocked();
486 EXPECT_TRUE(session_.HasPendingHandshake());
488 InSequence s;
489 // Force most streams to re-register, which is common scenario when we block
490 // the Crypto stream, and only the crypto stream can "really" write.
492 // Due to prioritization, we *should* be asked to write the crypto stream
493 // first.
494 // Don't re-register the crypto stream (which signals complete writing).
495 TestCryptoStream* crypto_stream = session_.GetCryptoStream();
496 EXPECT_CALL(*crypto_stream, OnCanWrite());
498 // Re-register all other streams, to show they weren't able to proceed.
499 EXPECT_CALL(*stream2, OnCanWrite())
500 .WillOnce(Invoke(&stream2_blocker, &StreamBlocker::MarkWriteBlocked));
501 EXPECT_CALL(*stream3, OnCanWrite())
502 .WillOnce(Invoke(&stream3_blocker, &StreamBlocker::MarkWriteBlocked));
503 EXPECT_CALL(*stream4, OnCanWrite())
504 .WillOnce(Invoke(&stream4_blocker, &StreamBlocker::MarkWriteBlocked));
506 session_.OnCanWrite();
507 EXPECT_TRUE(session_.WillingAndAbleToWrite());
508 EXPECT_FALSE(session_.HasPendingHandshake()); // Crypto stream wrote.
511 TEST_P(QuicSessionTest, OnCanWriteWithClosedStream) {
512 TestStream* stream2 = session_.CreateOutgoingDataStream();
513 TestStream* stream4 = session_.CreateOutgoingDataStream();
514 TestStream* stream6 = session_.CreateOutgoingDataStream();
516 session_.MarkWriteBlocked(stream2->id(), kSomeMiddlePriority);
517 session_.MarkWriteBlocked(stream6->id(), kSomeMiddlePriority);
518 session_.MarkWriteBlocked(stream4->id(), kSomeMiddlePriority);
519 CloseStream(stream6->id());
521 InSequence s;
522 EXPECT_CALL(*stream2, OnCanWrite());
523 EXPECT_CALL(*stream4, OnCanWrite());
524 session_.OnCanWrite();
525 EXPECT_FALSE(session_.WillingAndAbleToWrite());
528 TEST_P(QuicSessionTest, OnCanWriteLimitsNumWritesIfFlowControlBlocked) {
529 // Ensure connection level flow control blockage.
530 QuicFlowControllerPeer::SetSendWindowOffset(session_.flow_controller(), 0);
531 EXPECT_TRUE(session_.flow_controller()->IsBlocked());
532 EXPECT_TRUE(session_.IsConnectionFlowControlBlocked());
533 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
535 // Mark the crypto and headers streams as write blocked, we expect them to be
536 // allowed to write later.
537 session_.MarkWriteBlocked(kCryptoStreamId, kHighestPriority);
538 session_.MarkWriteBlocked(kHeadersStreamId, kHighestPriority);
540 // Create a data stream, and although it is write blocked we never expect it
541 // to be allowed to write as we are connection level flow control blocked.
542 TestStream* stream = session_.CreateOutgoingDataStream();
543 session_.MarkWriteBlocked(stream->id(), kSomeMiddlePriority);
544 EXPECT_CALL(*stream, OnCanWrite()).Times(0);
546 // The crypto and headers streams should be called even though we are
547 // connection flow control blocked.
548 TestCryptoStream* crypto_stream = session_.GetCryptoStream();
549 EXPECT_CALL(*crypto_stream, OnCanWrite()).Times(1);
550 TestHeadersStream* headers_stream = new TestHeadersStream(&session_);
551 QuicSessionPeer::SetHeadersStream(&session_, headers_stream);
552 EXPECT_CALL(*headers_stream, OnCanWrite()).Times(1);
554 session_.OnCanWrite();
555 EXPECT_FALSE(session_.WillingAndAbleToWrite());
558 TEST_P(QuicSessionTest, SendGoAway) {
559 EXPECT_CALL(*connection_,
560 SendGoAway(QUIC_PEER_GOING_AWAY, 0u, "Going Away."));
561 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away.");
562 EXPECT_TRUE(session_.goaway_sent());
564 EXPECT_CALL(*connection_,
565 SendRstStream(3u, QUIC_STREAM_PEER_GOING_AWAY, 0)).Times(0);
566 EXPECT_TRUE(session_.GetIncomingDataStream(3u));
569 TEST_P(QuicSessionTest, DoNotSendGoAwayTwice) {
570 EXPECT_CALL(*connection_,
571 SendGoAway(QUIC_PEER_GOING_AWAY, 0u, "Going Away.")).Times(1);
572 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away.");
573 EXPECT_TRUE(session_.goaway_sent());
574 session_.SendGoAway(QUIC_PEER_GOING_AWAY, "Going Away.");
577 TEST_P(QuicSessionTest, IncreasedTimeoutAfterCryptoHandshake) {
578 EXPECT_EQ(kInitialIdleTimeoutSecs + 3,
579 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
580 CryptoHandshakeMessage msg;
581 session_.GetCryptoStream()->OnHandshakeMessage(msg);
582 EXPECT_EQ(kMaximumIdleTimeoutSecs + 3,
583 QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
586 TEST_P(QuicSessionTest, RstStreamBeforeHeadersDecompressed) {
587 // Send two bytes of payload.
588 QuicStreamFrame data1(kClientDataStreamId1, false, 0, MakeIOVector("HT"));
589 vector<QuicStreamFrame> frames;
590 frames.push_back(data1);
591 session_.OnStreamFrames(frames);
592 EXPECT_EQ(1u, session_.GetNumOpenStreams());
594 EXPECT_CALL(*connection_, SendRstStream(kClientDataStreamId1, _, _));
595 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0);
596 session_.OnRstStream(rst1);
597 EXPECT_EQ(0u, session_.GetNumOpenStreams());
598 // Connection should remain alive.
599 EXPECT_TRUE(connection_->connected());
602 TEST_P(QuicSessionTest, MultipleRstStreamsCauseSingleConnectionClose) {
603 // If multiple invalid reset stream frames arrive in a single packet, this
604 // should trigger a connection close. However there is no need to send
605 // multiple connection close frames.
607 // Create valid stream.
608 QuicStreamFrame data1(kClientDataStreamId1, false, 0, MakeIOVector("HT"));
609 vector<QuicStreamFrame> frames;
610 frames.push_back(data1);
611 session_.OnStreamFrames(frames);
612 EXPECT_EQ(1u, session_.GetNumOpenStreams());
614 // Process first invalid stream reset, resulting in the connection being
615 // closed.
616 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID))
617 .Times(1);
618 QuicStreamId kLargeInvalidStreamId = 99999999;
619 QuicRstStreamFrame rst1(kLargeInvalidStreamId, QUIC_STREAM_NO_ERROR, 0);
620 session_.OnRstStream(rst1);
621 QuicConnectionPeer::CloseConnection(connection_);
623 // Processing of second invalid stream reset should not result in the
624 // connection being closed for a second time.
625 QuicRstStreamFrame rst2(kLargeInvalidStreamId, QUIC_STREAM_NO_ERROR, 0);
626 session_.OnRstStream(rst2);
629 TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedStream) {
630 // Test that if a stream is flow control blocked, then on receipt of the SHLO
631 // containing a suitable send window offset, the stream becomes unblocked.
633 // Ensure that Writev consumes all the data it is given (simulate no socket
634 // blocking).
635 session_.set_writev_consumes_all_data(true);
637 // Create a stream, and send enough data to make it flow control blocked.
638 TestStream* stream2 = session_.CreateOutgoingDataStream();
639 string body(kMinimumFlowControlSendWindow, '.');
640 EXPECT_FALSE(stream2->flow_controller()->IsBlocked());
641 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
642 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
643 EXPECT_CALL(*connection_, SendBlocked(stream2->id()));
644 EXPECT_CALL(*connection_, SendBlocked(0));
645 stream2->SendBody(body, false);
646 EXPECT_TRUE(stream2->flow_controller()->IsBlocked());
647 EXPECT_TRUE(session_.IsConnectionFlowControlBlocked());
648 EXPECT_TRUE(session_.IsStreamFlowControlBlocked());
650 // The handshake message will call OnCanWrite, so the stream can resume
651 // writing.
652 EXPECT_CALL(*stream2, OnCanWrite());
653 // Now complete the crypto handshake, resulting in an increased flow control
654 // send window.
655 CryptoHandshakeMessage msg;
656 session_.GetCryptoStream()->OnHandshakeMessage(msg);
658 // Stream is now unblocked.
659 EXPECT_FALSE(stream2->flow_controller()->IsBlocked());
660 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
661 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
664 TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedCryptoStream) {
665 // Test that if the crypto stream is flow control blocked, then if the SHLO
666 // contains a larger send window offset, the stream becomes unblocked.
667 session_.set_writev_consumes_all_data(true);
668 TestCryptoStream* crypto_stream = session_.GetCryptoStream();
669 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked());
670 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
671 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
672 QuicHeadersStream* headers_stream =
673 QuicSessionPeer::GetHeadersStream(&session_);
674 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
675 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
676 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
677 // Write until the crypto stream is flow control blocked.
678 EXPECT_CALL(*connection_, SendBlocked(kCryptoStreamId));
679 int i = 0;
680 while (!crypto_stream->flow_controller()->IsBlocked() && i < 1000) {
681 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
682 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
683 QuicConfig config;
684 CryptoHandshakeMessage crypto_message;
685 config.ToHandshakeMessage(&crypto_message);
686 crypto_stream->SendHandshakeMessage(crypto_message);
687 ++i;
689 EXPECT_TRUE(crypto_stream->flow_controller()->IsBlocked());
690 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
691 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
692 EXPECT_TRUE(session_.IsStreamFlowControlBlocked());
693 EXPECT_FALSE(session_.HasDataToWrite());
694 EXPECT_TRUE(crypto_stream->HasBufferedData());
696 // The handshake message will call OnCanWrite, so the stream can
697 // resume writing.
698 EXPECT_CALL(*crypto_stream, OnCanWrite());
699 // Now complete the crypto handshake, resulting in an increased flow control
700 // send window.
701 CryptoHandshakeMessage msg;
702 session_.GetCryptoStream()->OnHandshakeMessage(msg);
704 // Stream is now unblocked and will no longer have buffered data.
705 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked());
706 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
707 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
710 TEST_P(QuicSessionTest, HandshakeUnblocksFlowControlBlockedHeadersStream) {
711 // Test that if the header stream is flow control blocked, then if the SHLO
712 // contains a larger send window offset, the stream becomes unblocked.
713 session_.set_writev_consumes_all_data(true);
714 TestCryptoStream* crypto_stream = session_.GetCryptoStream();
715 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked());
716 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
717 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
718 QuicHeadersStream* headers_stream =
719 QuicSessionPeer::GetHeadersStream(&session_);
720 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
721 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
722 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
723 QuicStreamId stream_id = 5;
724 // Write until the header stream is flow control blocked.
725 EXPECT_CALL(*connection_, SendBlocked(kHeadersStreamId));
726 SpdyHeaderBlock headers;
727 while (!headers_stream->flow_controller()->IsBlocked() && stream_id < 2000) {
728 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
729 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
730 headers["header"] = base::Uint64ToString(base::RandUint64()) +
731 base::Uint64ToString(base::RandUint64()) +
732 base::Uint64ToString(base::RandUint64());
733 headers_stream->WriteHeaders(stream_id, headers, true, 0, nullptr);
734 stream_id += 2;
736 // Write once more to ensure that the headers stream has buffered data. The
737 // random headers may have exactly filled the flow control window.
738 headers_stream->WriteHeaders(stream_id, headers, true, 0, nullptr);
739 EXPECT_TRUE(headers_stream->HasBufferedData());
741 EXPECT_TRUE(headers_stream->flow_controller()->IsBlocked());
742 EXPECT_FALSE(crypto_stream->flow_controller()->IsBlocked());
743 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
744 EXPECT_TRUE(session_.IsStreamFlowControlBlocked());
745 EXPECT_FALSE(session_.HasDataToWrite());
747 // Now complete the crypto handshake, resulting in an increased flow control
748 // send window.
749 CryptoHandshakeMessage msg;
750 session_.GetCryptoStream()->OnHandshakeMessage(msg);
752 // Stream is now unblocked and will no longer have buffered data.
753 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
754 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
755 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
756 EXPECT_FALSE(headers_stream->HasBufferedData());
759 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstOutOfOrder) {
760 // Test that when we receive an out of order stream RST we correctly adjust
761 // our connection level flow control receive window.
762 // On close, the stream should mark as consumed all bytes between the highest
763 // byte consumed so far and the final byte offset from the RST frame.
764 TestStream* stream = session_.CreateOutgoingDataStream();
766 const QuicStreamOffset kByteOffset =
767 1 + kInitialSessionFlowControlWindowForTest / 2;
769 // Expect no stream WINDOW_UPDATE frames, as stream read side closed.
770 EXPECT_CALL(*connection_, SendWindowUpdate(stream->id(), _)).Times(0);
771 // We do expect a connection level WINDOW_UPDATE when the stream is reset.
772 EXPECT_CALL(*connection_,
773 SendWindowUpdate(0, kInitialSessionFlowControlWindowForTest +
774 kByteOffset)).Times(1);
776 EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
777 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED,
778 kByteOffset);
779 session_.OnRstStream(rst_frame);
780 session_.PostProcessAfterData();
781 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed());
784 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAndLocalReset) {
785 // Test the situation where we receive a FIN on a stream, and before we fully
786 // consume all the data from the sequencer buffer we locally RST the stream.
787 // The bytes between highest consumed byte, and the final byte offset that we
788 // determined when the FIN arrived, should be marked as consumed at the
789 // connection level flow controller when the stream is reset.
790 TestStream* stream = session_.CreateOutgoingDataStream();
792 const QuicStreamOffset kByteOffset =
793 kInitialSessionFlowControlWindowForTest / 2;
794 QuicStreamFrame frame(stream->id(), true, kByteOffset, IOVector());
795 vector<QuicStreamFrame> frames;
796 frames.push_back(frame);
797 session_.OnStreamFrames(frames);
798 session_.PostProcessAfterData();
799 EXPECT_TRUE(connection_->connected());
801 EXPECT_EQ(0u, stream->flow_controller()->bytes_consumed());
802 EXPECT_EQ(kByteOffset,
803 stream->flow_controller()->highest_received_byte_offset());
805 // Reset stream locally.
806 EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
807 stream->Reset(QUIC_STREAM_CANCELLED);
808 EXPECT_EQ(kByteOffset, session_.flow_controller()->bytes_consumed());
811 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingFinAfterRst) {
812 // Test that when we RST the stream (and tear down stream state), and then
813 // receive a FIN from the peer, we correctly adjust our connection level flow
814 // control receive window.
816 // Connection starts with some non-zero highest received byte offset,
817 // due to other active streams.
818 const uint64 kInitialConnectionBytesConsumed = 567;
819 const uint64 kInitialConnectionHighestReceivedOffset = 1234;
820 EXPECT_LT(kInitialConnectionBytesConsumed,
821 kInitialConnectionHighestReceivedOffset);
822 session_.flow_controller()->UpdateHighestReceivedOffset(
823 kInitialConnectionHighestReceivedOffset);
824 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed);
826 // Reset our stream: this results in the stream being closed locally.
827 TestStream* stream = session_.CreateOutgoingDataStream();
828 EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
829 stream->Reset(QUIC_STREAM_CANCELLED);
831 // Now receive a response from the peer with a FIN. We should handle this by
832 // adjusting the connection level flow control receive window to take into
833 // account the total number of bytes sent by the peer.
834 const QuicStreamOffset kByteOffset = 5678;
835 string body = "hello";
836 IOVector data = MakeIOVector(body);
837 QuicStreamFrame frame(stream->id(), true, kByteOffset, data);
838 vector<QuicStreamFrame> frames;
839 frames.push_back(frame);
840 session_.OnStreamFrames(frames);
842 QuicStreamOffset total_stream_bytes_sent_by_peer =
843 kByteOffset + body.length();
844 EXPECT_EQ(kInitialConnectionBytesConsumed + total_stream_bytes_sent_by_peer,
845 session_.flow_controller()->bytes_consumed());
846 EXPECT_EQ(
847 kInitialConnectionHighestReceivedOffset + total_stream_bytes_sent_by_peer,
848 session_.flow_controller()->highest_received_byte_offset());
851 TEST_P(QuicSessionTest, ConnectionFlowControlAccountingRstAfterRst) {
852 // Test that when we RST the stream (and tear down stream state), and then
853 // receive a RST from the peer, we correctly adjust our connection level flow
854 // control receive window.
856 // Connection starts with some non-zero highest received byte offset,
857 // due to other active streams.
858 const uint64 kInitialConnectionBytesConsumed = 567;
859 const uint64 kInitialConnectionHighestReceivedOffset = 1234;
860 EXPECT_LT(kInitialConnectionBytesConsumed,
861 kInitialConnectionHighestReceivedOffset);
862 session_.flow_controller()->UpdateHighestReceivedOffset(
863 kInitialConnectionHighestReceivedOffset);
864 session_.flow_controller()->AddBytesConsumed(kInitialConnectionBytesConsumed);
866 // Reset our stream: this results in the stream being closed locally.
867 TestStream* stream = session_.CreateOutgoingDataStream();
868 EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
869 stream->Reset(QUIC_STREAM_CANCELLED);
871 // Now receive a RST from the peer. We should handle this by adjusting the
872 // connection level flow control receive window to take into account the total
873 // number of bytes sent by the peer.
874 const QuicStreamOffset kByteOffset = 5678;
875 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED,
876 kByteOffset);
877 session_.OnRstStream(rst_frame);
879 EXPECT_EQ(kInitialConnectionBytesConsumed + kByteOffset,
880 session_.flow_controller()->bytes_consumed());
881 EXPECT_EQ(kInitialConnectionHighestReceivedOffset + kByteOffset,
882 session_.flow_controller()->highest_received_byte_offset());
885 TEST_P(QuicSessionTest, InvalidStreamFlowControlWindowInHandshake) {
886 // Test that receipt of an invalid (< default) stream flow control window from
887 // the peer results in the connection being torn down.
888 uint32 kInvalidWindow = kMinimumFlowControlSendWindow - 1;
889 QuicConfigPeer::SetReceivedInitialStreamFlowControlWindow(session_.config(),
890 kInvalidWindow);
892 EXPECT_CALL(*connection_,
893 SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW));
894 session_.OnConfigNegotiated();
897 TEST_P(QuicSessionTest, InvalidSessionFlowControlWindowInHandshake) {
898 // Test that receipt of an invalid (< default) session flow control window
899 // from the peer results in the connection being torn down.
900 uint32 kInvalidWindow = kMinimumFlowControlSendWindow - 1;
901 QuicConfigPeer::SetReceivedInitialSessionFlowControlWindow(session_.config(),
902 kInvalidWindow);
904 EXPECT_CALL(*connection_,
905 SendConnectionClose(QUIC_FLOW_CONTROL_INVALID_WINDOW));
906 session_.OnConfigNegotiated();
909 TEST_P(QuicSessionTest, FlowControlWithInvalidFinalOffset) {
910 // Test that if we receive a stream RST with a highest byte offset that
911 // violates flow control, that we close the connection.
912 const uint64 kLargeOffset = kInitialSessionFlowControlWindowForTest + 1;
913 EXPECT_CALL(*connection_,
914 SendConnectionClose(QUIC_FLOW_CONTROL_RECEIVED_TOO_MUCH_DATA))
915 .Times(2);
917 // Check that stream frame + FIN results in connection close.
918 TestStream* stream = session_.CreateOutgoingDataStream();
919 EXPECT_CALL(*connection_, SendRstStream(stream->id(), _, _));
920 stream->Reset(QUIC_STREAM_CANCELLED);
921 QuicStreamFrame frame(stream->id(), true, kLargeOffset, IOVector());
922 vector<QuicStreamFrame> frames;
923 frames.push_back(frame);
924 session_.OnStreamFrames(frames);
926 // Check that RST results in connection close.
927 QuicRstStreamFrame rst_frame(stream->id(), QUIC_STREAM_CANCELLED,
928 kLargeOffset);
929 session_.OnRstStream(rst_frame);
932 TEST_P(QuicSessionTest, WindowUpdateUnblocksHeadersStream) {
933 // Test that a flow control blocked headers stream gets unblocked on recipt of
934 // a WINDOW_UPDATE frame. Regression test for b/17413860.
936 // Set the headers stream to be flow control blocked.
937 QuicHeadersStream* headers_stream =
938 QuicSessionPeer::GetHeadersStream(&session_);
939 QuicFlowControllerPeer::SetSendWindowOffset(headers_stream->flow_controller(),
941 EXPECT_TRUE(headers_stream->flow_controller()->IsBlocked());
942 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
943 EXPECT_TRUE(session_.IsStreamFlowControlBlocked());
945 // Unblock the headers stream by supplying a WINDOW_UPDATE.
946 QuicWindowUpdateFrame window_update_frame(headers_stream->id(),
947 2 * kMinimumFlowControlSendWindow);
948 vector<QuicWindowUpdateFrame> frames;
949 frames.push_back(window_update_frame);
950 session_.OnWindowUpdateFrames(frames);
951 EXPECT_FALSE(headers_stream->flow_controller()->IsBlocked());
952 EXPECT_FALSE(session_.IsConnectionFlowControlBlocked());
953 EXPECT_FALSE(session_.IsStreamFlowControlBlocked());
956 TEST_P(QuicSessionTest, TooManyUnfinishedStreamsCauseConnectionClose) {
957 // If a buggy/malicious peer creates too many streams that are not ended with
958 // a FIN or RST then we send a connection close.
959 EXPECT_CALL(*connection_,
960 SendConnectionClose(QUIC_TOO_MANY_UNFINISHED_STREAMS)).Times(1);
962 const int kMaxStreams = 5;
963 QuicSessionPeer::SetMaxOpenStreams(&session_, kMaxStreams);
965 // Create kMaxStreams + 1 data streams, and close them all without receiving a
966 // FIN or a RST from the client.
967 const int kFirstStreamId = kClientDataStreamId1;
968 const int kFinalStreamId = kClientDataStreamId1 + 2 * kMaxStreams + 1;
969 for (int i = kFirstStreamId; i < kFinalStreamId; i += 2) {
970 QuicStreamFrame data1(i, false, 0, MakeIOVector("HT"));
971 vector<QuicStreamFrame> frames;
972 frames.push_back(data1);
973 session_.OnStreamFrames(frames);
974 EXPECT_EQ(1u, session_.GetNumOpenStreams());
975 EXPECT_CALL(*connection_, SendRstStream(i, _, _));
976 session_.CloseStream(i);
979 // Called after any new data is received by the session, and triggers the call
980 // to close the connection.
981 session_.PostProcessAfterData();
984 } // namespace
985 } // namespace test
986 } // namespace net