Move logic that ignores pushed request headers into QuicSpdySession::SpdyFramerVisitor. Simplify logic by using a Boolean instead of a QuicStreamId; remove QuicSpdySession::OnPushPromise(). PiperOrigin-RevId: 572697017
diff --git a/quiche/quic/core/http/quic_spdy_session.cc b/quiche/quic/core/http/quic_spdy_session.cc index d2376e6..f82ce1c 100644 --- a/quiche/quic/core/http/quic_spdy_session.cc +++ b/quiche/quic/core/http/quic_spdy_session.cc
@@ -197,9 +197,11 @@ /* is_sent = */ false, header_list_.compressed_header_bytes(), header_list_.uncompressed_header_bytes()); - if (session_->IsConnected()) { + // Ignore pushed request headers. + if (session_->IsConnected() && !expecting_pushed_headers_) { session_->OnHeaderList(header_list_); } + expecting_pushed_headers_ = false; header_list_.Clear(); } @@ -355,8 +357,8 @@ QUIC_INVALID_HEADERS_STREAM_DATA); } - void OnPushPromise(SpdyStreamId stream_id, SpdyStreamId promised_stream_id, - bool /*end*/) override { + void OnPushPromise(SpdyStreamId /*stream_id*/, + SpdyStreamId promised_stream_id, bool /*end*/) override { QUICHE_DCHECK(!VersionUsesHttp3(session_->transport_version())); if (session_->perspective() != Perspective::IS_CLIENT) { // PUSH_PROMISE sent by a client is a protocol violation. @@ -370,12 +372,9 @@ promised_stream_id, QuicResetStreamError::FromInternal(QUIC_REFUSED_STREAM), /* bytes_written = */ 0); - if (!session_->IsConnected()) { - return; - } - // Notify session nonetheless so that it can identify incoming headers - // as belonging to the push. - session_->OnPushPromise(stream_id, promised_stream_id); + + QUICHE_DCHECK(!expecting_pushed_headers_); + expecting_pushed_headers_ = true; } void OnContinuation(SpdyStreamId /*stream_id*/, size_t /*payload_size*/, @@ -439,6 +438,10 @@ QuicSpdySession* session_; QuicHeaderList header_list_; + + // True if the next OnHeaderFrameEnd() call signals the end of pushed request + // headers. + bool expecting_pushed_headers_ = false; }; Http3DebugVisitor::Http3DebugVisitor() {} @@ -470,8 +473,6 @@ max_outbound_header_list_size_(std::numeric_limits<size_t>::max()), stream_id_( QuicUtils::GetInvalidStreamId(connection->transport_version())), - promised_stream_id_( - QuicUtils::GetInvalidStreamId(connection->transport_version())), frame_len_(0), fin_(false), spdy_framer_(SpdyFramer::ENABLE_COMPRESSION), @@ -1389,22 +1390,10 @@ } QUICHE_DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), stream_id_); - QUICHE_DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), - promised_stream_id_); stream_id_ = stream_id; fin_ = fin; } -void QuicSpdySession::OnPushPromise(SpdyStreamId stream_id, - SpdyStreamId promised_stream_id) { - QUICHE_DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), - stream_id_); - QUICHE_DCHECK_EQ(QuicUtils::GetInvalidStreamId(transport_version()), - promised_stream_id_); - stream_id_ = stream_id; - promised_stream_id_ = promised_stream_id; -} - // TODO (wangyix): Why is SpdyStreamId used instead of QuicStreamId? // This occurs in many places in this file. void QuicSpdySession::OnPriority(SpdyStreamId stream_id, @@ -1422,13 +1411,9 @@ << ": " << header_list.DebugString(); QUICHE_DCHECK(!VersionUsesHttp3(transport_version())); - // Ignore push request headers. - if (promised_stream_id_ == - QuicUtils::GetInvalidStreamId(transport_version())) { - OnStreamHeaderList(stream_id_, fin_, frame_len_, header_list); - } + OnStreamHeaderList(stream_id_, fin_, frame_len_, header_list); + // Reset state for the next frame. - promised_stream_id_ = QuicUtils::GetInvalidStreamId(transport_version()); stream_id_ = QuicUtils::GetInvalidStreamId(transport_version()); fin_ = false; frame_len_ = 0;
diff --git a/quiche/quic/core/http/quic_spdy_session.h b/quiche/quic/core/http/quic_spdy_session.h index ada9d8c..59d73be 100644 --- a/quiche/quic/core/http/quic_spdy_session.h +++ b/quiche/quic/core/http/quic_spdy_session.h
@@ -326,8 +326,6 @@ // Called when the complete list of headers is available. void OnHeaderList(const QuicHeaderList& header_list); - QuicStreamId promised_stream_id() const { return promised_stream_id_; } - // Initialze HTTP/3 unidirectional streams if |unidirectional| is true and // those streams are not initialized yet. void OnCanCreateNewOutgoingStream(bool unidirectional) override; @@ -644,7 +642,6 @@ // Data about the stream whose headers are being processed. QuicStreamId stream_id_; - QuicStreamId promised_stream_id_; size_t frame_len_; bool fin_;