Skip to content

Commit 8f3987f

Browse files
authored
feature: add function to bypass HTTP conditional request checks (#2401)
I hereby granted the copyright of the changes in this pull request to the authors of this lua-nginx-module project. releated: #2397 refer: nginx/nginx@d9887ee Signed-off-by: tzssangglass <[email protected]> * refactor: modify bypass_if_checks function to return void Signed-off-by: tzssangglass <[email protected]> --------- Signed-off-by: tzssangglass <[email protected]>
1 parent cb0b22d commit 8f3987f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/ngx_http_lua_util.c

+6
Original file line numberDiff line numberDiff line change
@@ -4555,4 +4555,10 @@ ngx_http_lua_parse_addr(lua_State *L, u_char *text, size_t len)
45554555
}
45564556

45574557

4558+
void
4559+
ngx_http_lua_ffi_bypass_if_checks(ngx_http_request_t *r)
4560+
{
4561+
r->disable_not_modified = 1;
4562+
}
4563+
45584564
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

t/014-bugs.t

+30
Original file line numberDiff line numberDiff line change
@@ -1366,3 +1366,33 @@ If-Match: 1
13661366
--- error_code: 412
13671367
--- response_body eval
13681368
qr/\Ahello\z/
1369+
1370+
1371+
1372+
=== TEST 50: nginx crashes when encountering an illegal http if header
1373+
crash with ngx.print()
1374+
--- main_config
1375+
--- config
1376+
error_page 412 /my_error_handler_412;
1377+
1378+
location /t {
1379+
access_by_lua_block {
1380+
local ngx_resp = require "ngx.resp"
1381+
ngx_resp.bypass_if_checks()
1382+
ngx.print("hello")
1383+
ngx.exit(200)
1384+
}
1385+
}
1386+
location = /my_error_handler_412 {
1387+
content_by_lua_block {
1388+
ngx.sleep(0.002)
1389+
ngx.header["Content-Type"] = "text/plain"
1390+
}
1391+
}
1392+
--- request
1393+
GET /t
1394+
--- more_headers
1395+
If-Match: 1
1396+
--- error_code: 200
1397+
--- response_body eval
1398+
qr/\Ahello\z/

0 commit comments

Comments
 (0)