Chromium Code Reviews| 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/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 EXPECT_TRUE(AtEof()); | 604 EXPECT_TRUE(AtEof()); |
| 605 } | 605 } |
| 606 | 606 |
| 607 TEST_P(QuicHttpStreamTest, DestroyedEarly) { | 607 TEST_P(QuicHttpStreamTest, DestroyedEarly) { |
| 608 SetRequest("GET", "/", DEFAULT_PRIORITY); | 608 SetRequest("GET", "/", DEFAULT_PRIORITY); |
| 609 if (GetParam() > QUIC_VERSION_12) { | 609 if (GetParam() > QUIC_VERSION_12) { |
| 610 AddWrite(ConstructRequestHeadersPacket(1, kFin)); | 610 AddWrite(ConstructRequestHeadersPacket(1, kFin)); |
| 611 } else { | 611 } else { |
| 612 AddWrite(ConstructDataPacket(1, kIncludeVersion, kFin, 0, request_data_)); | 612 AddWrite(ConstructDataPacket(1, kIncludeVersion, kFin, 0, request_data_)); |
| 613 } | 613 } |
| 614 AddWrite(ConstructRstStreamPacket(2)); | 614 // TODO(rtenneti): Looks like the following is not needed. |
| 615 // AddWrite(ConstructRstStreamPacket(2)); | |
|
Ryan Hamilton
2014/01/27 19:08:02
Do you understand why the RST_STREAM packet is not
ramant (doing other things)
2014/01/29 00:40:19
Thanks for your help. Undid this change. Replaced
| |
| 615 use_closing_stream_ = true; | 616 use_closing_stream_ = true; |
| 616 Initialize(); | 617 Initialize(); |
| 617 | 618 |
| 618 request_.method = "GET"; | 619 request_.method = "GET"; |
| 619 request_.url = GURL("http://www.google.com/"); | 620 request_.url = GURL("http://www.google.com/"); |
| 620 | 621 |
| 621 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, | 622 EXPECT_EQ(OK, stream_->InitializeStream(&request_, DEFAULT_PRIORITY, |
| 622 net_log_, callback_.callback())); | 623 net_log_, callback_.callback())); |
| 623 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, | 624 EXPECT_EQ(OK, stream_->SendRequest(headers_, &response_, |
| 624 callback_.callback())); | 625 callback_.callback())); |
| 625 EXPECT_EQ(&response_, stream_->GetResponseInfo()); | 626 EXPECT_EQ(&response_, stream_->GetResponseInfo()); |
| 626 | 627 |
| 627 // Ack the request. | 628 // Ack the request. |
| 628 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 629 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
| 629 EXPECT_EQ(ERR_IO_PENDING, | 630 EXPECT_EQ(ERR_IO_PENDING, |
| 630 stream_->ReadResponseHeaders(callback_.callback())); | 631 stream_->ReadResponseHeaders(callback_.callback())); |
| 631 | 632 |
| 632 // Send the response with a body. | 633 // Send the response with a body. |
| 633 SetResponse("404 OK", "hello world!"); | 634 SetResponse("404 OK", "hello world!"); |
| 635 ProcessPacket(ConstructAckPacket(2, 0, 0)); | |
| 634 // In the course of processing this packet, the QuicHttpStream close itself. | 636 // In the course of processing this packet, the QuicHttpStream close itself. |
| 635 if (GetParam() > QUIC_VERSION_12) { | 637 if (GetParam() > QUIC_VERSION_12) { |
| 636 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); | 638 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); |
| 637 } else { | 639 } else { |
| 638 ProcessPacket(ConstructDataPacket(2, false, kFin, 0, response_data_)); | 640 ProcessPacket(ConstructDataPacket(2, false, kFin, 0, response_data_)); |
| 639 } | 641 } |
| 640 | 642 |
| 641 EXPECT_TRUE(AtEof()); | 643 EXPECT_TRUE(AtEof()); |
| 642 } | 644 } |
| 643 | 645 |
| 644 TEST_P(QuicHttpStreamTest, Priority) { | 646 TEST_P(QuicHttpStreamTest, Priority) { |
| 645 SetRequest("GET", "/", MEDIUM); | 647 SetRequest("GET", "/", MEDIUM); |
| 646 if (GetParam() > QUIC_VERSION_12) { | 648 if (GetParam() > QUIC_VERSION_12) { |
| 647 AddWrite(ConstructRequestHeadersPacket(1, kFin)); | 649 AddWrite(ConstructRequestHeadersPacket(1, kFin)); |
| 648 } else { | 650 } else { |
| 649 AddWrite(ConstructDataPacket(1, kIncludeVersion, kFin, 0, request_data_)); | 651 AddWrite(ConstructDataPacket(1, kIncludeVersion, kFin, 0, request_data_)); |
| 650 } | 652 } |
| 651 AddWrite(ConstructRstStreamPacket(2)); | 653 // TODO(rtenneti): Looks like the following is not needed. |
| 654 // AddWrite(ConstructRstStreamPacket(2)); | |
| 652 use_closing_stream_ = true; | 655 use_closing_stream_ = true; |
| 653 Initialize(); | 656 Initialize(); |
| 654 | 657 |
| 655 request_.method = "GET"; | 658 request_.method = "GET"; |
| 656 request_.url = GURL("http://www.google.com/"); | 659 request_.url = GURL("http://www.google.com/"); |
| 657 | 660 |
| 658 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, | 661 EXPECT_EQ(OK, stream_->InitializeStream(&request_, MEDIUM, |
| 659 net_log_, callback_.callback())); | 662 net_log_, callback_.callback())); |
| 660 | 663 |
| 661 // Check that priority is highest. | 664 // Check that priority is highest. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 673 DCHECK_EQ(MEDIUM, ConvertQuicPriorityToRequestPriority( | 676 DCHECK_EQ(MEDIUM, ConvertQuicPriorityToRequestPriority( |
| 674 reliable_stream->EffectivePriority())); | 677 reliable_stream->EffectivePriority())); |
| 675 | 678 |
| 676 // Ack the request. | 679 // Ack the request. |
| 677 ProcessPacket(ConstructAckPacket(1, 0, 0)); | 680 ProcessPacket(ConstructAckPacket(1, 0, 0)); |
| 678 EXPECT_EQ(ERR_IO_PENDING, | 681 EXPECT_EQ(ERR_IO_PENDING, |
| 679 stream_->ReadResponseHeaders(callback_.callback())); | 682 stream_->ReadResponseHeaders(callback_.callback())); |
| 680 | 683 |
| 681 // Send the response with a body. | 684 // Send the response with a body. |
| 682 SetResponse("404 OK", "hello world!"); | 685 SetResponse("404 OK", "hello world!"); |
| 686 ProcessPacket(ConstructAckPacket(2, 0, 0)); | |
| 683 // In the course of processing this packet, the QuicHttpStream close itself. | 687 // In the course of processing this packet, the QuicHttpStream close itself. |
| 684 if (GetParam() > QUIC_VERSION_12) { | 688 if (GetParam() > QUIC_VERSION_12) { |
| 685 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); | 689 ProcessPacket(ConstructResponseHeadersPacket(2, kFin)); |
| 686 } else { | 690 } else { |
| 687 ProcessPacket(ConstructDataPacket(2, !kIncludeVersion, kFin, 0, | 691 ProcessPacket(ConstructDataPacket(2, !kIncludeVersion, kFin, 0, |
| 688 response_data_)); | 692 response_data_)); |
| 689 } | 693 } |
| 690 | 694 |
| 691 EXPECT_TRUE(AtEof()); | 695 EXPECT_TRUE(AtEof()); |
| 692 } | 696 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 750 WillRepeatedly(Return(QuicTime::Delta::Zero())); | 754 WillRepeatedly(Return(QuicTime::Delta::Zero())); |
| 751 | 755 |
| 752 // Data should flush out now. | 756 // Data should flush out now. |
| 753 connection_->OnCanWrite(); | 757 connection_->OnCanWrite(); |
| 754 EXPECT_FALSE(reliable_stream->HasBufferedData()); | 758 EXPECT_FALSE(reliable_stream->HasBufferedData()); |
| 755 EXPECT_TRUE(AtEof()); | 759 EXPECT_TRUE(AtEof()); |
| 756 } | 760 } |
| 757 | 761 |
| 758 } // namespace test | 762 } // namespace test |
| 759 } // namespace net | 763 } // namespace net |
| OLD | NEW |