Skip to content

Commit

Permalink
connect_grpc_bridge: remove request content-length (envoyproxy#30363)
Browse files Browse the repository at this point in the history
We need to always remove Content-Length since the request on the other
side of the filter is chunked with a different body size.

Signed-off-by: Martin Conte Mac Donell <[email protected]>
  • Loading branch information
Reflejo authored Oct 21, 2023
1 parent a98cafb commit c18432e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/extensions/filters/http/connect_grpc_bridge/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,9 @@ Http::FilterHeadersStatus ConnectGrpcBridgeFilter::decodeHeaders(Http::RequestHe
unary_payload_frame_flags_ |= Envoy::Grpc::GRPC_FH_COMPRESSED;
}

headers.removeContentLength();

if (end_stream) {
headers.removeContentLength();
Grpc::Encoder().prependFrameHeader(unary_payload_frame_flags_, request_buffer_);
decoder_callbacks_->addDecodedData(request_buffer_, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,14 @@ TEST_F(ConnectGrpcBridgeFilterTest, UnaryRequestWithNoBodyNorTrailers) {
EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_.decodeHeaders(request_headers_, true));
}

TEST_F(ConnectGrpcBridgeFilterTest, UnaryRequestRemovesContentLength) {
request_headers_.setCopy(Http::CustomHeaders::get().ConnectProtocolVersion, "1");
request_headers_.setContentType(Http::Headers::get().ContentTypeValues.Grpc);
request_headers_.setContentLength(1337);
EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_.decodeHeaders(request_headers_, false));
EXPECT_EQ("", request_headers_.get_("content-length"));
}

TEST_F(ConnectGrpcBridgeFilterTest, StreamingSupportedContentType) {
request_headers_.setContentType("application/connect+proto");
EXPECT_EQ(Http::FilterHeadersStatus::Continue, filter_.decodeHeaders(request_headers_, false));
Expand Down

0 comments on commit c18432e

Please sign in to comment.