Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Schore <mike.schore@gmail.com>
  • Loading branch information
goaway committed Sep 18, 2020
1 parent 65f023e commit 3691127
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand Down
38 changes: 27 additions & 11 deletions library/common/extensions/filters/http/platform_bridge/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 4 additions & 8 deletions library/common/extensions/filters/http/platform_bridge/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3691127

Please sign in to comment.