Skip to content

Commit

Permalink
runtime: remove dont_add_content_length_for_bodiless_requests (#18484)
Browse files Browse the repository at this point in the history
Fixes #18434
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
  • Loading branch information
alyssawilk authored Oct 11, 2021
1 parent 8d33116 commit 9cd7457
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 25 deletions.
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Removed Config or Runtime
*Normally occurs at the end of the* :ref:`deprecation period <deprecated>`

* compression: removed ``envoy.reloadable_features.enable_compression_without_content_length_header`` runtime guard and legacy code paths.
* http: removed ``envoy.reloadable_features.dont_add_content_length_for_bodiless_requests deprecation`` and legacy code paths.
* http: removed ``envoy.reloadable_features.return_502_for_upstream_protocol_errors``. Envoy will always return 502 code upon encountering upstream protocol error.
* http: removed ``envoy.reloadable_features.treat_upstream_connect_timeout_as_connect_failure`` and legacy code paths.

Expand Down
4 changes: 1 addition & 3 deletions source/common/http/http1/codec_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ void StreamEncoderImpl::encodeHeadersBase(const RequestOrResponseHeaderMap& head
// Also do not add content length for requests which should not have a
// body, per https://tools.ietf.org/html/rfc7230#section-3.3.2
if (!status || (*status >= 200 && *status != 204)) {
if (!bodiless_request ||
!Runtime::runtimeFeatureEnabled(
"envoy.reloadable_features.dont_add_content_length_for_bodiless_requests")) {
if (!bodiless_request) {
encodeFormattedHeader(header_values.ContentLength.get(), "0", formatter);
}
}
Expand Down
1 change: 0 additions & 1 deletion source/common/runtime/runtime_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ constexpr const char* runtime_features[] = {
"envoy.reloadable_features.conn_pool_delete_when_idle",
"envoy.reloadable_features.correct_scheme_and_xfp",
"envoy.reloadable_features.disable_tls_inspector_injection",
"envoy.reloadable_features.dont_add_content_length_for_bodiless_requests",
"envoy.reloadable_features.fix_added_trailers",
"envoy.reloadable_features.grpc_bridge_stats_disabled",
"envoy.reloadable_features.grpc_web_fix_non_proto_encoded_response_handling",
Expand Down
19 changes: 0 additions & 19 deletions test/common/http/http1/codec_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2260,25 +2260,6 @@ TEST_F(Http1ClientConnectionImplTest, SimpleGetWithHeaderCasing) {
EXPECT_EQ("GET / HTTP/1.1\r\nMy-Custom-Header: hey\r\n\r\n", output);
}

TEST_F(Http1ClientConnectionImplTest, SimpleGetWithHeaderCasingLegacy) {
TestScopedRuntime scoped_runtime;
Runtime::LoaderSingleton::getExisting()->mergeValues(
{{"envoy.reloadable_features.dont_add_content_length_for_bodiless_requests", "false"}});
codec_settings_.header_key_format_ = Http1Settings::HeaderKeyFormat::ProperCase;

initialize();

MockResponseDecoder response_decoder;
Http::RequestEncoder& request_encoder = codec_->newStream(response_decoder);

std::string output;
ON_CALL(connection_, write(_, _)).WillByDefault(AddBufferToString(&output));

TestRequestHeaderMapImpl headers{{":method", "GET"}, {":path", "/"}, {"my-custom-header", "hey"}};
EXPECT_TRUE(request_encoder.encodeHeaders(headers, true).ok());
EXPECT_EQ("GET / HTTP/1.1\r\nMy-Custom-Header: hey\r\nContent-Length: 0\r\n\r\n", output);
}

TEST_F(Http1ClientConnectionImplTest, HostHeaderTranslate) {
initialize();

Expand Down
2 changes: 0 additions & 2 deletions test/integration/protocol_integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ TEST_P(DownstreamProtocolIntegrationTest, RouterRedirect) {
}

TEST_P(ProtocolIntegrationTest, UnknownResponsecode) {
config_helper_.addRuntimeOverride(
"envoy.reloadable_features.dont_add_content_length_for_bodiless_requests", "true");
initialize();

codec_client_ = makeHttpConnection(lookupPort("http"));
Expand Down

0 comments on commit 9cd7457

Please sign in to comment.