Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: net/spdy/bidirectional_stream_spdy_impl_unittest.cc

Issue 2462463002: Make net::BidirectionalStream handle RST_STREAM_NO_ERROR (Closed)
Patch Set: self review Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/spdy/bidirectional_stream_spdy_impl.h" 5 #include "net/spdy/bidirectional_stream_spdy_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 EXPECT_EQ(0, delegate->on_data_read_count()); 425 EXPECT_EQ(0, delegate->on_data_read_count());
426 EXPECT_EQ(0, delegate->on_data_sent_count()); 426 EXPECT_EQ(0, delegate->on_data_sent_count());
427 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); 427 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol());
428 // BidirectionalStreamSpdyStreamJob does not count the bytes sent for |rst| 428 // BidirectionalStreamSpdyStreamJob does not count the bytes sent for |rst|
429 // because it is sent after SpdyStream::Delegate::OnClose is called. 429 // because it is sent after SpdyStream::Delegate::OnClose is called.
430 EXPECT_EQ(CountWriteBytes(writes, 1), delegate->GetTotalSentBytes()); 430 EXPECT_EQ(CountWriteBytes(writes, 1), delegate->GetTotalSentBytes());
431 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), 431 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)),
432 delegate->GetTotalReceivedBytes()); 432 delegate->GetTotalReceivedBytes());
433 } 433 }
434 434
435 // Tests that when received RST_STREAM with NO_ERROR, BidirectionalStream does
436 // not crash when processing pending writes. See crbug.com/650438.
437 TEST_F(BidirectionalStreamSpdyImplTest, RstWithNoErrorBeforeSendIsComplete) {
438 SpdySerializedFrame req(spdy_util_.ConstructSpdyPost(
439 kDefaultUrl, 1, kBodyDataSize * 3, LOW, nullptr, 0));
440 MockWrite writes[] = {CreateMockWrite(req, 0)};
441
442 SpdySerializedFrame resp(spdy_util_.ConstructSpdyPostReply(nullptr, 0));
443 SpdySerializedFrame rst(
444 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_NO_ERROR));
445 MockRead reads[] = {CreateMockRead(resp, 1), CreateMockRead(rst, 2),
446 MockRead(ASYNC, 0, 3)};
447
448 InitSession(reads, arraysize(reads), writes, arraysize(writes));
449
450 BidirectionalStreamRequestInfo request_info;
451 request_info.method = "POST";
452 request_info.url = default_url_;
453 request_info.extra_headers.SetHeader(net::HttpRequestHeaders::kContentLength,
454 base::SizeTToString(kBodyDataSize * 3));
455
456 scoped_refptr<IOBuffer> read_buffer(new IOBuffer(kReadBufferSize));
457 std::unique_ptr<TestDelegateBase> delegate(
458 new TestDelegateBase(session_, read_buffer.get(), kReadBufferSize));
459 delegate->SetRunUntilCompletion(true);
460 delegate->Start(&request_info, net_log_.bound());
461 base::RunLoop().RunUntilIdle();
462
463 EXPECT_FALSE(delegate->on_failed_called());
464
465 for (size_t i = 0; i < 3; i++) {
466 scoped_refptr<StringIOBuffer> write_buffer(
467 new StringIOBuffer(std::string(kBodyData, kBodyDataSize)));
468 delegate->SendData(write_buffer.get(), write_buffer->size(), i == 2);
469 base::RunLoop().RunUntilIdle();
470 }
471 delegate->WaitUntilCompletion();
472 LoadTimingInfo load_timing_info;
473 EXPECT_TRUE(delegate->GetLoadTimingInfo(&load_timing_info));
474 TestLoadTimingNotReused(load_timing_info);
475
476 EXPECT_THAT(delegate->error(), IsError(OK));
477 EXPECT_EQ(1, delegate->on_data_read_count());
478 EXPECT_EQ(3, delegate->on_data_sent_count());
479 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol());
480 EXPECT_EQ(CountWriteBytes(writes, 1), delegate->GetTotalSentBytes());
481 // Should not count RST stream.
482 EXPECT_EQ(CountReadBytes(reads, arraysize(reads) - 2),
483 delegate->GetTotalReceivedBytes());
484 }
485
435 } // namespace net 486 } // namespace net
OLDNEW
« net/spdy/bidirectional_stream_spdy_impl.cc ('K') | « net/spdy/bidirectional_stream_spdy_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698