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
4 changes: 2 additions & 2 deletions source/common/http/filter/lua/lua_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ int StreamHandleWrapper::luaRespond(lua_State* state) {
uint64_t status;
if (headers->Status() == nullptr ||
!StringUtil::atoul(headers->Status()->value().c_str(), status) || status < 200 ||
status >= 500) {
luaL_error(state, ":status must be between 100-599");
status >= 600) {
luaL_error(state, ":status must be between 200-599");
}

Buffer::InstancePtr body;
Expand Down
6 changes: 3 additions & 3 deletions test/common/http/filter/lua/lua_filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ TEST_F(LuaHttpFilterTest, ImmediateResponse) {
const std::string SCRIPT{R"EOF(
function envoy_on_request(request_handle)
request_handle:respond(
{[":status"] = "403"},
{[":status"] = "503"},
Copy link
Member

Choose a reason for hiding this comment

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

Why change this test response code? Both are in range..

Copy link
Member Author

Choose a reason for hiding this comment

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

Because this was what was broken before the change. :)

We test 4xx codes elsewhere.

"nope")

-- Should not run
Expand All @@ -1184,7 +1184,7 @@ TEST_F(LuaHttpFilterTest, ImmediateResponse) {
setup(SCRIPT);

TestHeaderMapImpl request_headers{{":path", "/"}};
TestHeaderMapImpl expected_headers{{":status", "403"}, {"content-length", "4"}};
TestHeaderMapImpl expected_headers{{":status", "503"}, {"content-length", "4"}};
EXPECT_CALL(decoder_callbacks_, encodeHeaders_(HeaderMapEqualRef(&expected_headers), false));
EXPECT_CALL(decoder_callbacks_, encodeData(_, true));
EXPECT_EQ(FilterHeadersStatus::StopIteration, filter_->decodeHeaders(request_headers, false));
Expand All @@ -1205,7 +1205,7 @@ TEST_F(LuaHttpFilterTest, ImmediateResponseBadStatus) {

TestHeaderMapImpl request_headers{{":path", "/"}};
EXPECT_CALL(*filter_, scriptLog(spdlog::level::err,
StrEq("[string \"...\"]:3: :status must be between 100-599")));
StrEq("[string \"...\"]:3: :status must be between 200-599")));
EXPECT_EQ(FilterHeadersStatus::Continue, filter_->decodeHeaders(request_headers, false));
}

Expand Down