Enforce header list size limit in QpackDecodedHeadersAccumulator.
Move header list size limit enforcement from QuicHeaderList to
QpackDecodedHeadersAccumulator when using IETF QUIC. This provides an explicit
signal, instead of having to rely on QuicHeaderList being empty.
Also change limit counting to account for 32 bytes of overhead per header field
as prescribed by the specification. Keep |uncompressed_size| passed in to
QuicHeaderList without this overhead, just like it is when called from
HpackDecoder::ListenerAdapter (used for Google QUIC) and from AsHeaderList (used
for tests).
gfe-relnote: n/a, change to QUIC v99-only code. Protected by existing disabled gfe2_reloadable_flag_quic_enable_version_99.
PiperOrigin-RevId: 282822239
Change-Id: If9b27ed3189cad5bfdb6be415196e7c0f2267a74
diff --git a/quic/core/http/quic_spdy_stream_test.cc b/quic/core/http/quic_spdy_stream_test.cc
index 39bd6b0..74ad6ef 100644
--- a/quic/core/http/quic_spdy_stream_test.cc
+++ b/quic/core/http/quic_spdy_stream_test.cc
@@ -346,26 +346,36 @@
TEST_P(QuicSpdyStreamTest, ProcessTooLargeHeaderList) {
Initialize(kShouldProcessData);
- QuicHeaderList headers;
- stream_->OnStreamHeadersPriority(
- spdy::SpdyStreamPrecedence(kV3HighestPriority));
+ if (!UsesHttp3()) {
+ QuicHeaderList headers;
+ stream_->OnStreamHeadersPriority(
+ spdy::SpdyStreamPrecedence(kV3HighestPriority));
- if (UsesHttp3()) {
- EXPECT_CALL(
- *connection_,
- CloseConnection(
- QUIC_HEADERS_STREAM_DATA_DECOMPRESS_FAILURE,
- MatchesRegex("Too large headers received on stream \\d+"), _));
- } else {
EXPECT_CALL(*session_,
SendRstStream(stream_->id(), QUIC_HEADERS_TOO_LARGE, 0));
- }
+ stream_->OnStreamHeaderList(false, 1 << 20, headers);
- stream_->OnStreamHeaderList(false, 1 << 20, headers);
-
- if (!UsesHttp3()) {
EXPECT_THAT(stream_->stream_error(), IsStreamError(QUIC_HEADERS_TOO_LARGE));
+
+ return;
}
+
+ // Header list size includes 32 bytes for overhead per header field.
+ session_->set_max_inbound_header_list_size(40);
+ std::string headers =
+ HeadersFrame({std::make_pair("foo", "too long headers")});
+
+ QuicStreamFrame frame(stream_->id(), false, 0, headers);
+
+ EXPECT_CALL(
+ *connection_,
+ CloseConnection(QUIC_HEADERS_STREAM_DATA_DECOMPRESS_FAILURE,
+ MatchesRegex("Too large headers received on stream \\d+"),
+ _));
+
+ stream_->OnStreamFrame(frame);
+
+ EXPECT_TRUE(stream_->header_list().empty());
}
TEST_P(QuicSpdyStreamTest, ProcessHeaderListWithFin) {