Modify QuicDataStream to break out headers processing from data processing.
This allows callers to parse headers without needing to determine their length,
potentially getting it wrong and hence introducing bugs.
Merge internal change: 97245844
Review URL: https://codereview.chromium.org/1222473002
Cr-Commit-Position: refs/heads/master@{#337082}
diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc
index 1fcbf27..412bd23 100644
--- a/net/quic/quic_http_stream_test.cc
+++ b/net/quic/quic_http_stream_test.cc
@@ -83,6 +83,8 @@
: QuicHttpStream(session) {
}
+ void OnHeadersAvailable(StringPiece headers) override { Close(false); }
+
int OnDataReceived(const char* data, int length) override {
Close(false);
return OK;
@@ -188,6 +190,8 @@
socket->Connect(peer_addr_);
runner_ = new TestTaskRunner(&clock_);
send_algorithm_ = new MockSendAlgorithm();
+ EXPECT_CALL(*send_algorithm_, InRecovery()).WillRepeatedly(Return(false));
+ EXPECT_CALL(*send_algorithm_, InSlowStart()).WillRepeatedly(Return(false));
EXPECT_CALL(*send_algorithm_,
OnPacketSent(_, _, _, _, _)).WillRepeatedly(Return(true));
EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly(
@@ -400,13 +404,10 @@
headers[":status"] = "200 OK";
headers[":version"] = "HTTP/1.1";
headers["content-type"] = "text/plain";
- headers["big6"] = std::string(10000, 'x'); // Lots of x's.
+ headers["big6"] = std::string(1000, 'x'); // Lots of x's.
- std::string response =
- SpdyUtils::SerializeUncompressedHeaders(headers, GetParam());
- EXPECT_LT(4096u, response.length());
- stream_->OnDataReceived(response.data(), response.length());
- stream_->OnClose(QUIC_NO_ERROR);
+ response_headers_ = headers;
+ ProcessPacket(ConstructResponseHeadersPacket(2, kFin));
// Now that the headers have been processed, the callback will return.
EXPECT_EQ(OK, callback_.WaitForResult());