Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: handle HTTP/2 Push as soft error #1139

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/cli/cli_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ bool CliConnection::OnEndHeadersForStream(http2::adapter::Http2StreamId stream_i
}
LOG(INFO) << "Connection (client) " << connection_id() << " for " << remote_domain() << " Padding support "
<< (padding_support_ ? "enabled" : "disabled") << " Backed by " << server_field << ".";

// we're done
request_map_.clear();
return true;
}

Expand Down Expand Up @@ -282,13 +285,15 @@ void CliConnection::OnConnectionError(ConnectionError error) {
}

bool CliConnection::OnFrameHeader(StreamId stream_id, size_t /*length*/, uint8_t /*type*/, uint8_t /*flags*/) {
if (stream_id && stream_id != stream_id_) {
LOG(WARNING) << "Connection (client) " << connection_id() << " refused unexpected HTTP/2 Push";
return false;
}
return true;
}

bool CliConnection::OnBeginHeadersForStream(StreamId stream_id) {
if (stream_id) {
DCHECK_EQ(stream_id, stream_id_) << "Client only support one stream";
}
DCHECK_EQ(stream_id, stream_id_) << "Unexpected http2 request stream: " << stream_id << " expected: " << stream_id_;
return true;
}

Expand Down
18 changes: 12 additions & 6 deletions src/server/server_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,9 @@ bool ServerConnection::OnEndHeadersForStream(http2::adapter::Http2StreamId strea
padding_support_ = false;
}

// we're done
request_map_.clear();

SetState(state_stream);
OnConnect();
return true;
Expand Down Expand Up @@ -389,19 +392,22 @@ void ServerConnection::OnConnectionError(ConnectionError error) {
}

bool ServerConnection::OnFrameHeader(StreamId stream_id, size_t /*length*/, uint8_t /*type*/, uint8_t /*flags*/) {
return true;
}

bool ServerConnection::OnBeginHeadersForStream(StreamId stream_id) {
// we begin with new stream
if (!stream_id_) {
stream_id_ = stream_id;
}
if (stream_id) {
DCHECK_EQ(stream_id, stream_id_) << "Server only support one stream";
if (stream_id && stream_id != stream_id_) {
LOG(INFO) << "Connection (server) " << connection_id() << " refused new stream: " << stream_id;
return false;
}
return true;
}

bool ServerConnection::OnBeginHeadersForStream(StreamId stream_id) {
DCHECK_EQ(stream_id, stream_id_) << "Unexpected http2 request stream: " << stream_id << " expected: " << stream_id_;
return true;
}

bool ServerConnection::OnBeginDataForStream(StreamId stream_id, size_t payload_length) {
return true;
}
Expand Down