diff --git a/library/common/extensions/filters/http/platform_bridge/c_types.h b/library/common/extensions/filters/http/platform_bridge/c_types.h index e585631b44..a381117c64 100644 --- a/library/common/extensions/filters/http/platform_bridge/c_types.h +++ b/library/common/extensions/filters/http/platform_bridge/c_types.h @@ -12,6 +12,7 @@ extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinue; extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopIteration; extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinueAndEndStream; extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopAllIterationAndBuffer; +extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusResumeIteration; /** * Compound return type for on-headers filter invocations. @@ -28,6 +29,7 @@ typedef int envoy_filter_data_status_t; extern const envoy_filter_data_status_t kEnvoyFilterDataStatusContinue; extern const envoy_filter_data_status_t kEnvoyFilterDataStatusStopIterationAndBuffer; extern const envoy_filter_data_status_t kEnvoyFilterDataStatusStopIterationNoBuffer; +extern const envoy_filter_data_status_t kEnvoyFilterDataStatusResumeIteration; /** * Compound return type for on-data filter invocations. @@ -44,6 +46,7 @@ typedef struct { typedef int envoy_filter_trailers_status_t; extern const envoy_filter_trailers_status_t kEnvoyFilterTrailersStatusContinue; extern const envoy_filter_trailers_status_t kEnvoyFilterTrailersStatusStopIteration; +extern const envoy_filter_trailers_status_t kEnvoyFilterTrailersStatusResumeIteration; /** * Compound return type for on-trailers filter invocations. diff --git a/library/common/extensions/filters/http/platform_bridge/filter.cc b/library/common/extensions/filters/http/platform_bridge/filter.cc index 3d1d79db5f..114453944a 100644 --- a/library/common/extensions/filters/http/platform_bridge/filter.cc +++ b/library/common/extensions/filters/http/platform_bridge/filter.cc @@ -127,34 +127,50 @@ PlatformBridgeFilter::onTrailers(Http::HeaderMap& trailers, Http::FilterHeadersStatus PlatformBridgeFilter::decodeHeaders(Http::RequestHeaderMap& headers, bool end_stream) { // Delegate to shared implementation for request and response path. - return onHeaders(headers, end_stream, platform_filter_.on_request_headers); + auto status = onHeaders(headers, end_stream, platform_filter_.on_request_headers); + if (status == Http::FilterHeadersStatus::StopIteration) { + pending_request_headers_ = &headers; + } + return status; } -Http::FilterDataStatus PlatformBridgeFilter::decodeData(Buffer::Instance& data, bool end_stream) { +Http::FilterHeadersStatus PlatformBridgeFilter::encodeHeaders(Http::ResponseHeaderMap& headers, + bool end_stream) { // Delegate to shared implementation for request and response path. - return onData(data, end_stream, platform_filter_.on_request_data); + auto status = onHeaders(headers, end_stream, platform_filter_.on_response_headers); + if (status == Http::FilterHeadersStatus::StopIteration) { + pending_response_headers_ = &headers; + } + return status; } -Http::FilterTrailersStatus PlatformBridgeFilter::decodeTrailers(Http::RequestTrailerMap& trailers) { +Http::FilterDataStatus PlatformBridgeFilter::decodeData(Buffer::Instance& data, bool end_stream) { // Delegate to shared implementation for request and response path. - return onTrailers(trailers, platform_filter_.on_request_trailers); + return onData(data, end_stream, platform_filter_.on_request_data); } -Http::FilterHeadersStatus PlatformBridgeFilter::encodeHeaders(Http::ResponseHeaderMap& headers, - bool end_stream) { +Http::FilterDataStatus PlatformBridgeFilter::encodeData(Buffer::Instance& data, bool end_stream) { // Delegate to shared implementation for request and response path. - return onHeaders(headers, end_stream, platform_filter_.on_response_headers); + return onData(data, end_stream, platform_filter_.on_response_data); } -Http::FilterDataStatus PlatformBridgeFilter::encodeData(Buffer::Instance& data, bool end_stream) { +Http::FilterTrailersStatus PlatformBridgeFilter::decodeTrailers(Http::RequestTrailerMap& trailers) { // Delegate to shared implementation for request and response path. - return onData(data, end_stream, platform_filter_.on_response_data); + auto status = onTrailers(trailers, platform_filter_.on_request_trailers); + if (status == Http::FilterTrailersStatus::StopIteration) { + pending_request_trailers_ = &trailers; + } + return status; } Http::FilterTrailersStatus PlatformBridgeFilter::encodeTrailers(Http::ResponseTrailerMap& trailers) { // Delegate to shared implementation for request and response path. - return onTrailers(trailers, platform_filter_.on_response_trailers); + auto status = onTrailers(trailers, platform_filter_.on_response_trailers); + if (status == Http::FilterTrailersStatus::StopIteration) { + pending_response_trailers_ = &trailers; + } + return status; } } // namespace PlatformBridge diff --git a/library/common/extensions/filters/http/platform_bridge/filter.h b/library/common/extensions/filters/http/platform_bridge/filter.h index f942c8cbea..079d0ab006 100644 --- a/library/common/extensions/filters/http/platform_bridge/filter.h +++ b/library/common/extensions/filters/http/platform_bridge/filter.h @@ -61,14 +61,10 @@ class PlatformBridgeFilter final : public Http::PassThroughFilter, envoy_filter_on_trailers_f on_trailers); const std::string filter_name_; envoy_http_filter platform_filter_; - Http::RequestHeaderMap* pending_request_headers_; - Http::ResponseHeaderMap* pending_response_headers_; - Http::RequestTrailerMap* pending_request_trailers_; - Http::ResponseTrialerMap* pending_response_trailers_; - bool forwarded_request_headers_ = false; - bool forwarded_request_end_stream_ = false; - bool forwarded_response_headers_ = false; - bool forwarded_response_end_stream_ = false; + Http::RequestHeaderMap* pending_request_headers_{}; + Http::ResponseHeaderMap* pending_response_headers_{}; + Http::RequestTrailerMap* pending_request_trailers_{}; + Http::ResponseTrialerMap* pending_response_trailers_{}; }; } // namespace PlatformBridge