Skip to content

Commit 769b7bd

Browse files
committed
rename to allow_on_headers_stop_iteration
Rename option to allow_on_headers_stop_iteration and test onResponseHeaders behavior as well. Signed-off-by: Michael Warres <mpw@google.com>
1 parent 1afe902 commit 769b7bd

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

include/proxy-wasm/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ class ContextBase : public RootInterface,
402402
// translates FilterHeaderStatus::StopIteration to
403403
// FilterHeadersStatus::StopAllIterationAndWatermark, which is the default
404404
// behavior for v0.2.* of the Proxy-Wasm ABI.
405-
bool allow_on_request_headers_stop_iteration_ = false;
405+
bool allow_on_headers_stop_iteration_ = false;
406406

407407
private:
408408
// helper functions

src/context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ FilterHeadersStatus ContextBase::convertVmCallResultToFilterHeadersStatus(uint64
494494
return FilterHeadersStatus::StopAllIterationAndWatermark;
495495
}
496496
if (result == static_cast<uint64_t>(FilterHeadersStatus::StopIteration) &&
497-
!allow_on_request_headers_stop_iteration_) {
497+
!allow_on_headers_stop_iteration_) {
498498
// Default behavior for Proxy-Wasm 0.2.* ABI is to translate StopIteration
499499
// (pause processing headers, but continue processing body) to
500500
// StopAllIterationAndWatermark (pause all processing), as described in

test/stop_iteration_test.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ INSTANTIATE_TEST_SUITE_P(WasmEngines, TestVm, testing::ValuesIn(getWasmEngines()
2424
});
2525

2626
// TestVm is parameterized for each engine and creates a VM on construction.
27-
TEST_P(TestVm, AllowOnRequestHeadersStopIteration) {
27+
TEST_P(TestVm, AllowOnHeadersStopIteration) {
2828
// Read the wasm source.
2929
auto source = readTestWasmFile("stop_iteration.wasm");
3030
ASSERT_FALSE(source.empty());
@@ -47,8 +47,8 @@ TEST_P(TestVm, AllowOnRequestHeadersStopIteration) {
4747
// On the root context, call onConfigure().
4848
ASSERT_TRUE(wasm->configure(root_context, plugin));
4949

50-
// By default, stream context onRequestHeaders translates
51-
// FilterHeadersStatus::StopIteration to
50+
// By default, stream context onRequestHeaders and onResponseHeaders
51+
// translates FilterHeadersStatus::StopIteration to
5252
// FilterHeadersStatus::StopAllIterationAndWatermark.
5353
{
5454
auto wasm_handle = std::make_shared<WasmHandleBase>(wasm);
@@ -57,7 +57,8 @@ TEST_P(TestVm, AllowOnRequestHeadersStopIteration) {
5757
stream_context.onCreate();
5858
EXPECT_EQ(stream_context.onRequestHeaders(/*headers=*/0, /*end_of_stream=*/false),
5959
FilterHeadersStatus::StopAllIterationAndWatermark);
60-
stream_context.onResponseHeaders(/*headers=*/0, /*end_of_stream=*/false);
60+
EXPECT_EQ(stream_context.onResponseHeaders(/*headers=*/0, /*end_of_stream=*/false),
61+
FilterHeadersStatus::StopAllIterationAndWatermark);
6162
stream_context.onDone();
6263
stream_context.onDelete();
6364
}
@@ -68,11 +69,12 @@ TEST_P(TestVm, AllowOnRequestHeadersStopIteration) {
6869
auto wasm_handle = std::make_shared<WasmHandleBase>(wasm);
6970
auto plugin_handle = std::make_shared<PluginHandleBase>(wasm_handle, plugin);
7071
auto stream_context = TestContext(wasm.get(), root_context->id(), plugin_handle);
71-
stream_context.set_allow_on_request_headers_stop_iteration(true);
72+
stream_context.set_allow_on_headers_stop_iteration(true);
7273
stream_context.onCreate();
7374
EXPECT_EQ(stream_context.onRequestHeaders(/*headers=*/0, /*end_of_stream=*/false),
7475
FilterHeadersStatus::StopIteration);
75-
stream_context.onResponseHeaders(/*headers=*/0, /*end_of_stream=*/false);
76+
EXPECT_EQ(stream_context.onResponseHeaders(/*headers=*/0, /*end_of_stream=*/false),
77+
FilterHeadersStatus::StopIteration);
7678
stream_context.onDone();
7779
stream_context.onDelete();
7880
}

test/test_data/stop_iteration.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class StopIterationContext : public Context {
2121
FilterHeadersStatus onRequestHeaders(uint32_t headers, bool end_of_stream) override {
2222
return FilterHeadersStatus::StopIteration;
2323
}
24+
25+
FilterHeadersStatus onResponseHeaders(uint32_t headers, bool end_of_stream) override {
26+
return FilterHeadersStatus::StopIteration;
27+
}
2428
};
2529

2630
static RegisterContextFactory register_StaticContext(CONTEXT_FACTORY(StopIterationContext),

test/utility.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ class TestContext : public ContextBase {
133133
.count();
134134
}
135135

136-
void set_allow_on_request_headers_stop_iteration(bool allow) {
137-
allow_on_request_headers_stop_iteration_ = allow;
136+
void set_allow_on_headers_stop_iteration(bool allow) {
137+
allow_on_headers_stop_iteration_ = allow;
138138
}
139139

140140
private:

0 commit comments

Comments
 (0)