Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fix lua-nginx-module context was clear when ngx.send_header() trigger filter_finalize case #2323

Merged
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: 4 additions & 0 deletions src/ngx_http_lua_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,10 @@ ngx_http_lua_send_header_if_needed(ngx_http_request_t *r,
if (!ctx->buffering) {
dd("sending headers");
rc = ngx_http_send_header(r);
if (r->filter_finalize) {
ngx_http_set_ctx(r, ctx, ngx_http_lua_module);
}

ctx->header_sent = 1;
return rc;
}
Expand Down
22 changes: 22 additions & 0 deletions t/002-content.t
Original file line number Diff line number Diff line change
Expand Up @@ -1098,3 +1098,25 @@ failed to load inlined Lua code: content_by_lua(...45678901234567890123456789012
GET /lua
--- response_body_like: 503 Service Temporarily Unavailable
--- error_code: 503



=== TEST 52: send_header trigger filter finalize does not clear the ctx
--- config
location /lua {
content_by_lua_block {
ngx.header["Last-Modified"] = ngx.http_time(ngx.time())
ngx.send_headers()
local phase = ngx.get_phase()
}
header_filter_by_lua_block {
ngx.header["X-Hello-World"] = "Hello World"
}
}
--- request
GET /lua
--- more_headers
If-Unmodified-Since: Wed, 01 Jan 2020 07:28:00 GMT
--- error_code: 412
--- no_error_log
unknown phase: 0
Loading