Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions source/extensions/filters/http/ext_authz/ext_authz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ void FilterConfigPerRoute::merge(const FilterConfigPerRoute& other) {
}

void Filter::initiateCall(const Http::HeaderMap& headers) {
if (filter_return_ == FilterReturn::StopDecoding) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return;
}

Router::RouteConstSharedPtr route = callbacks_->route();
if (route == nullptr || route->routeEntry() == nullptr) {
return;
Expand Down Expand Up @@ -96,8 +100,10 @@ Http::FilterHeadersStatus Filter::decodeHeaders(Http::HeaderMap& headers, bool e

Http::FilterDataStatus Filter::decodeData(Buffer::Instance&, bool end_stream) {
if (buffer_data_) {
if (end_stream || isBufferFull()) {
ENVOY_STREAM_LOG(debug, "ext_authz filter finished buffering the request", *callbacks_);
const bool buffer_is_full = isBufferFull();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we guard this in initiateCall?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me try.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified in c6b9334.

if (end_stream || buffer_is_full) {
ENVOY_STREAM_LOG(debug, "ext_authz filter finished buffering the request since {}",
*callbacks_, buffer_is_full ? "buffer is full" : "stream is ended");
initiateCall(*request_headers_);
return filter_return_ == FilterReturn::StopDecoding
? Http::FilterDataStatus::StopIterationAndWatermark
Expand Down
4 changes: 4 additions & 0 deletions test/extensions/filters/http/ext_authz/ext_authz_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,11 @@ TEST_F(HttpFilterTest, RequestDataWithPartialMessage) {
EXPECT_EQ(Http::FilterDataStatus::StopIterationAndBuffer, filter_->decodeData(data_, false));

data_.add("barfoo");
EXPECT_EQ(Http::FilterDataStatus::StopIterationAndWatermark, filter_->decodeData(data_, false));

data_.add("more data after watermark is set is possible");
EXPECT_EQ(Http::FilterDataStatus::StopIterationAndWatermark, filter_->decodeData(data_, true));

EXPECT_EQ(Http::FilterTrailersStatus::StopIteration, filter_->decodeTrailers(request_headers_));
}

Expand Down