Skip to content

Commit

Permalink
bugfix: remove http2 hardcode limitation in ngx.location subrequest…
Browse files Browse the repository at this point in the history
… API.
  • Loading branch information
oowl authored Nov 6, 2024
1 parent 501ebac commit 950b1fb
Show file tree
Hide file tree
Showing 20 changed files with 60 additions and 60 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ env:
#- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.1w TEST_NGINX_USE_HTTP2=1
- NGINX_VERSION=1.27.1 OPENSSL_VER=1.1.1w OPENSSL_PATCH_VER=1.1.1f TEST_NGINX_TIMEOUT=5 PCRE_VER=8.45
- NGINX_VERSION=1.27.1 OPENSSL_VER=3.0.15 OPENSSL_PATCH_VER=3.0.15 TEST_NGINX_TIMEOUT=5 PCRE2_VER=10.42
- NGINX_VERSION=1.27.1 OPENSSL_VER=1.1.1w OPENSSL_PATCH_VER=1.1.1f TEST_NGINX_TIMEOUT=5 PCRE_VER=8.45 TEST_NGINX_USE_HTTP2=1
- NGINX_VERSION=1.27.1 OPENSSL_VER=3.0.15 OPENSSL_PATCH_VER=3.0.15 TEST_NGINX_TIMEOUT=5 PCRE2_VER=10.42 TEST_NGINX_USE_HTTP2=1
- NGINX_VERSION=1.27.1 OPENSSL_VER=3.0.15 OPENSSL_PATCH_VER=3.0.15 TEST_NGINX_USE_HTTP3=1 TEST_NGINX_QUIC_IDLE_TIMEOUT=3 PCRE2_VER=10.42
- NGINX_VERSION=1.27.1 BORINGSSL=1 TEST_NGINX_USE_HTTP3=1 TEST_NGINX_QUIC_IDLE_TIMEOUT=3 PCRE2_VER=10.42

Expand Down
6 changes: 0 additions & 6 deletions src/ngx_http_lua_subrequest.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ ngx_http_lua_ngx_location_capture_multi(lua_State *L)
return luaL_error(L, "no request object found");
}

#if (NGX_HTTP_V2)
if (r->main->stream) {
return luaL_error(L, "http2 requests not supported yet");
}
#endif

ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
if (ctx == NULL) {
return luaL_error(L, "no ctx found");
Expand Down
5 changes: 5 additions & 0 deletions t/005-exit.t
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ GET /api?user=agentz

=== TEST 6: working with ngx_auth_request (simplest form, w/o ngx_memc)
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
--- no_http2
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down Expand Up @@ -197,6 +198,7 @@ Logged in 56

=== TEST 7: working with ngx_auth_request (simplest form)
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
--- no_http2
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down Expand Up @@ -269,6 +271,7 @@ Logged in 56


=== TEST 8: working with ngx_auth_request
--- no_http2
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
--- http_config eval
"
Expand Down Expand Up @@ -762,6 +765,7 @@ GET /t


=== TEST 27: accepts NGX_ERROR
--- no_http2
--- config
location = /t {
content_by_lua_block {
Expand All @@ -780,6 +784,7 @@ curl: (95) HTTP/3 stream 0 reset by server


=== TEST 28: accepts NGX_DECLINED
--- no_http2
--- config
location = /t {
content_by_lua_block {
Expand Down
2 changes: 1 addition & 1 deletion t/014-bugs.t
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2
header field names MUST be converted to lowercase prior to their
encoding in HTTP/2. A request or response containing uppercase
header field names MUST be treated as malformed

--- no_http2
--- config
location /sub {
content_by_lua '
Expand Down
1 change: 1 addition & 0 deletions t/016-resp-header.t
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ Fooy: cony1, cony2


=== TEST 15: set header after ngx.print
--- no_http2
--- config
location /lua {
default_type "text/plain";
Expand Down
1 change: 1 addition & 0 deletions t/020-subrequest.t
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ body:


=== TEST 43: subrequests with an output body filter returning NGX_ERROR
--- no_http2
--- config
location /sub {
echo hello world;
Expand Down
3 changes: 3 additions & 0 deletions t/023-rewrite/exit.t
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ GET /api?user=agentz


=== TEST 6: working with ngx_auth_request (simplest form, w/o ngx_memc)
--- no_http2
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down Expand Up @@ -192,6 +193,7 @@ Logged in 56


=== TEST 7: working with ngx_auth_request (simplest form)
--- no_http2
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down Expand Up @@ -264,6 +266,7 @@ Logged in 56


=== TEST 8: working with ngx_auth_request
--- no_http2
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down
3 changes: 3 additions & 0 deletions t/024-access/exit.t
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ GET /api?user=agentz


=== TEST 6: working with ngx_auth_request (simplest form, w/o ngx_memc)
--- no_http2
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down Expand Up @@ -182,6 +183,7 @@ Logged in 56


=== TEST 7: working with ngx_auth_request (simplest form)
--- no_http2
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down Expand Up @@ -249,6 +251,7 @@ Logged in 56


=== TEST 8: working with ngx_auth_request
--- no_http2
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down
1 change: 1 addition & 0 deletions t/026-mysql.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ run_tests();
__DATA__

=== TEST 1: when mysql query timed out, kill that query by Lua
--- no_http2
--- http_config
upstream backend {
drizzle_server 127.0.0.1:$TEST_NGINX_MYSQL_PORT protocol=mysql
Expand Down
2 changes: 1 addition & 1 deletion t/033-ctx.t
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ GET /t
--- error_log
ngx.ctx = 32
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand Down
46 changes: 24 additions & 22 deletions t/041-header-filter.t
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ GET /read
--- error_code
--- response_body
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand Down Expand Up @@ -449,6 +449,7 @@ GET /lua


=== TEST 21: lua error (string)
--- no_http2
--- config
location /lua {
set $foo '';
Expand All @@ -468,11 +469,12 @@ failed to run header_filter_by_lua*: header_filter_by_lua(nginx.conf:47):2: Some
--- no_error_log
[alert]
--- curl_error eval
qr/curl: \(56\) Failure when receiving data from the peer|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(56\) Failure when receiving data from the peer|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(28\) Remote peer returned unexpected data|curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server/



=== TEST 22: lua error (nil)
--- no_http2
--- config
location /lua {
set $foo '';
Expand All @@ -492,7 +494,7 @@ failed to run header_filter_by_lua*: unknown reason
--- no_error_log
[alert]
--- curl_error eval
qr/curl: \(56\) Failure when receiving data from the peer|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(56\) Failure when receiving data from the peer|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(28\) Remote peer returned unexpected data|curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -508,7 +510,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -524,7 +526,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -540,7 +542,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -556,7 +558,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -572,7 +574,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -592,7 +594,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -612,7 +614,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -628,7 +630,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -644,7 +646,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -660,7 +662,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand Down Expand Up @@ -694,7 +696,7 @@ GET /lua
--- error_log eval
qr/API disabled in the context of header_filter_by_lua\*|http3 requests are not supported without content-length header/ms
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -718,7 +720,7 @@ if (defined $ENV{TEST_NGINX_USE_HTTP3}) {

$err_log;
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -734,7 +736,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -750,7 +752,7 @@ GET /lua
--- error_log
API disabled in the context of header_filter_by_lua*
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand Down Expand Up @@ -799,7 +801,7 @@ in function 'error'
in function 'bar'
in function 'foo'
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand All @@ -819,7 +821,7 @@ GET /lua?a=1&b=2
--- error_log eval
qr/failed to load external Lua file ".*?test2\.lua": cannot open .*? No such file or directory/
--- curl_error eval
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 0 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/
qr/curl: \(52\) Empty reply from server|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly|curl: \(95\) HTTP\/3 stream 0 reset by server/



Expand Down Expand Up @@ -867,7 +869,7 @@ failed to load inlined Lua code: header_filter_by_lua(nginx.conf:41):2: unexpect
--- no_error_log
no_such_error
--- curl_error eval
qr/curl: \(56\) Failure when receiving data from the peer/
qr/curl: \(56\) Failure when receiving data from the peer|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly: INTERNAL_ERROR \(err 2\)/



Expand Down Expand Up @@ -898,7 +900,7 @@ failed to load inlined Lua code: header_filter_by_lua(nginx.conf:49):2: unexpect
--- no_error_log
no_such_error
--- curl_error eval
qr/curl: \(56\) Failure when receiving data from the peer/
qr/curl: \(56\) Failure when receiving data from the peer|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly: INTERNAL_ERROR \(err 2\)/



Expand All @@ -924,4 +926,4 @@ failed to load inlined Lua code: header_filter_by_lua(...90123456789012345678901
--- no_error_log
[alert]
--- curl_error eval
qr/curl: \(56\) Failure when receiving data from the peer/
qr/curl: \(56\) Failure when receiving data from the peer|curl: \(56\) Failure when receiving data from the peer|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly: INTERNAL_ERROR \(err 2\)/
3 changes: 1 addition & 2 deletions t/056-flush.t
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ GET /test
my @errlog;
if (defined $ENV{TEST_NGINX_USE_HTTP2}) {
@errlog = [
qr/lua writes elapsed 0\.[7-9]\d+ sec/,
qr/lua writes elapsed (?:0\.[7-9]\d+|[12]\.\d+) sec/,
qr/lua flush requires waiting: buffered 0x[0-9a-f]+, delayed:1/,
];
} else {
Expand All @@ -526,7 +526,6 @@ qr/lua flush requires waiting: buffered 0x[0-9a-f]+, delayed:1/,
];
}
@errlog;

--- no_error_log
[error]
--- timeout: 4
Loading

0 comments on commit 950b1fb

Please sign in to comment.