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

Unified Diff: net/quic/quic_spdy_stream_test.cc

Issue 1776423004: Only MarkTrailersConsumed when actually sending trailers notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add internal changes and fix tests Created 4 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_spdy_stream.cc ('k') | net/tools/quic/quic_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_spdy_stream_test.cc
diff --git a/net/quic/quic_spdy_stream_test.cc b/net/quic/quic_spdy_stream_test.cc
index 54ebb8a3fd0cd5ba9b628759cea96a3f65461d9d..40c76b3df5bd91d4cdf01f00829116058147db2c 100644
--- a/net/quic/quic_spdy_stream_test.cc
+++ b/net/quic/quic_spdy_stream_test.cc
@@ -631,6 +631,7 @@ TEST_P(QuicSpdyStreamTest, ReceivingTrailers) {
trailers_block["key1"] = "value1";
trailers_block["key2"] = "value2";
trailers_block["key3"] = "value3";
+ trailers_block[kFinalOffsetHeaderKey] = "0";
string trailers = SpdyUtils::SerializeUncompressedHeaders(trailers_block);
stream_->OnStreamHeaders(trailers);
stream_->OnStreamHeadersComplete(/*fin=*/true, trailers.size());
@@ -709,6 +710,44 @@ TEST_P(QuicSpdyStreamTest, ReceivingTrailersAfterBodyWithFin) {
stream_->OnStreamHeadersComplete(/*fin=*/true, trailers.size());
}
+TEST_P(QuicSpdyStreamTest, ReceivingTrailersWithOffset) {
+ // Test that when receiving trailing headers with an offset before response
+ // body, stream is closed at the right offset.
+ Initialize(kShouldProcessData);
+
+ // Receive initial headers.
+ string headers = SpdyUtils::SerializeUncompressedHeaders(headers_);
+ stream_->OnStreamHeaders(headers);
+ stream_->OnStreamHeadersComplete(false, headers.size());
+ stream_->MarkHeadersConsumed(stream_->decompressed_headers().size());
+
+ const string body = "this is the body";
+ // Receive trailing headers.
+ SpdyHeaderBlock trailers_block;
+ trailers_block["key1"] = "value1";
+ trailers_block["key2"] = "value2";
+ trailers_block["key3"] = "value3";
+ trailers_block[kFinalOffsetHeaderKey] = base::IntToString(body.size());
+ string trailers = SpdyUtils::SerializeUncompressedHeaders(trailers_block);
+ stream_->OnStreamHeaders(trailers);
+ stream_->OnStreamHeadersComplete(/*fin=*/true, trailers.size());
+
+ // The trailers should be decompressed, and readable from the stream.
+ EXPECT_TRUE(stream_->trailers_decompressed());
+ const string decompressed_trailers = stream_->decompressed_trailers();
+ EXPECT_EQ(trailers, decompressed_trailers);
+ // Consuming the trailers erases them from the stream.
+ stream_->MarkTrailersConsumed(decompressed_trailers.size());
+ EXPECT_EQ("", stream_->decompressed_trailers());
+
+ EXPECT_FALSE(stream_->IsDoneReading());
+ // Receive and consume body.
+ QuicStreamFrame frame(kClientDataStreamId1, /*fin=*/false, 0, body);
+ stream_->OnStreamFrame(frame);
+ EXPECT_EQ(body, stream_->data());
+ EXPECT_TRUE(stream_->IsDoneReading());
+}
+
TEST_P(QuicSpdyStreamTest, ClosingStreamWithNoTrailers) {
// Verify that a stream receiving headers, body, and no trailers is correctly
// marked as done reading on consumption of headers and body.
« no previous file with comments | « net/quic/quic_spdy_stream.cc ('k') | net/tools/quic/quic_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698