Skip to content

Commit 4a9d4b1

Browse files
committed
bugfix: subrequest response status codes between the range 100 .. 299 (inclusive) might get lost in the return values of ngx.location.capture*() calls. thanks Igor Clark for the report.
1 parent 2f65b0f commit 4a9d4b1

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

src/ngx_http_lua_subrequest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ ngx_http_lua_post_subrequest(ngx_http_request_t *r, void *data, ngx_int_t rc)
10041004
rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
10051005
}
10061006

1007-
if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
1007+
if (rc >= 100) {
10081008
pr_coctx->sr_statuses[ctx->index] = rc;
10091009
}
10101010
}

t/020-subrequest.t

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use Test::Nginx::Socket::Lua;
88
#log_level('warn');
99
#master_process_enabled(1);
1010

11+
no_root_location;
1112
repeat_each(2);
1213

1314
plan tests => repeat_each() * (blocks() * 3 + 22);
@@ -2797,3 +2798,76 @@ image header filter
27972798
--- no_error_log
27982799
[error]
27992800
2801+
2802+
2803+
=== TEST 75: WebDAV + MOVE
2804+
--- config
2805+
location = /t {
2806+
content_by_lua_block {
2807+
local file1 = "/file1.txt"
2808+
local file2 = "/file2.txt"
2809+
ngx.req.set_header( "Destination", file2 )
2810+
local res = ngx.location.capture(
2811+
file1, { method = ngx.HTTP_MOVE }
2812+
)
2813+
2814+
ngx.say(
2815+
"MOVE ", file1, " -> ", file2,
2816+
", response status: ", res.status
2817+
)
2818+
}
2819+
}
2820+
2821+
location / {
2822+
dav_methods MOVE;
2823+
}
2824+
2825+
--- user_files
2826+
>>> file1.txt
2827+
hello, world!
2828+
2829+
--- request
2830+
GET /t
2831+
2832+
--- response_body
2833+
MOVE /file1.txt -> /file2.txt, response status: 204
2834+
2835+
--- no_error_log
2836+
[error]
2837+
--- error_code: 200
2838+
2839+
2840+
2841+
=== TEST 76: WebDAV + DELETE
2842+
--- config
2843+
location = /t {
2844+
content_by_lua_block {
2845+
local file = "/file.txt"
2846+
local res = ngx.location.capture(
2847+
file, { method = ngx.HTTP_DELETE }
2848+
)
2849+
2850+
ngx.say(
2851+
"DELETE ", file,
2852+
", response status: ", res.status
2853+
)
2854+
}
2855+
}
2856+
2857+
location / {
2858+
dav_methods DELETE;
2859+
}
2860+
2861+
--- user_files
2862+
>>> file.txt
2863+
hello, world!
2864+
2865+
--- request
2866+
GET /t
2867+
2868+
--- response_body
2869+
DELETE /file.txt, response status: 204
2870+
2871+
--- no_error_log
2872+
[error]
2873+
--- error_code: 200

0 commit comments

Comments
 (0)