forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make http3 codec not encode empty trailers block (envoyproxy#35907)
Commit Message: Make http3 codec not encode empty trailers block Additional Description: http3 and `grpc_web_filter` combined resulted in an incompatibility with Chrome - a grpc web request received a response with an empty trailers block, which Chrome treats as a network error. The http2 codec had a special case in it for empty trailers, which was not mimicked in the http3 codec. This PR makes the http3 codec similar to the http2 codec in this respect, and adds an integration test ensuring that this behavior is in all downstream codecs. Risk Level: Small. It is a behavior change, but from an already malfunctioning state in a rare edge case. Testing: Added integration test which fails before the change and passes after. Docs Changes: n/a Release Notes: Yes Platform Specific Features: n/a --------- Signed-off-by: Raven Black <[email protected]>
- Loading branch information
1 parent
7b67799
commit b5bc273
Showing
7 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "envoy/registry/registry.h" | ||
#include "envoy/server/filter_config.h" | ||
|
||
#include "source/extensions/filters/http/common/pass_through_filter.h" | ||
|
||
#include "test/extensions/filters/http/common/empty_http_filter_config.h" | ||
#include "test/integration/filters/common.h" | ||
|
||
namespace Envoy { | ||
|
||
// Registers a filter which removes all trailers, leaving an empty trailers block. | ||
// This resembles the behavior of grpc_web_filter, so we can verify that the codecs | ||
// do the right thing when that happens. | ||
class RemoveResponseTrailersFilter : public Http::PassThroughFilter { | ||
public: | ||
constexpr static char name[] = "remove-response-trailers-filter"; | ||
Http::FilterTrailersStatus encodeTrailers(Http::ResponseTrailerMap& trailers) override { | ||
std::vector<std::string> keys; | ||
trailers.iterate([&keys](const Http::HeaderEntry& trailer) -> Http::HeaderMap::Iterate { | ||
keys.push_back(std::string(trailer.key().getStringView())); | ||
return Http::HeaderMap::Iterate::Continue; | ||
}); | ||
for (auto& k : keys) { | ||
const Http::LowerCaseString lower_key{k}; | ||
trailers.remove(lower_key); | ||
} | ||
return Http::FilterTrailersStatus::Continue; | ||
} | ||
}; | ||
|
||
static Registry::RegisterFactory<SimpleFilterConfig<RemoveResponseTrailersFilter>, | ||
Server::Configuration::NamedHttpFilterConfigFactory> | ||
register_; | ||
static Registry::RegisterFactory<SimpleFilterConfig<RemoveResponseTrailersFilter>, | ||
Server::Configuration::UpstreamHttpFilterConfigFactory> | ||
register_upstream_; | ||
|
||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters