Skip to content

Commit 950b1fb

Browse files
authored
bugfix: remove http2 hardcode limitation in ngx.location subrequest API.
1 parent 501ebac commit 950b1fb

20 files changed

+60
-60
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ env:
6363
#- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.1w TEST_NGINX_USE_HTTP2=1
6464
- NGINX_VERSION=1.27.1 OPENSSL_VER=1.1.1w OPENSSL_PATCH_VER=1.1.1f TEST_NGINX_TIMEOUT=5 PCRE_VER=8.45
6565
- NGINX_VERSION=1.27.1 OPENSSL_VER=3.0.15 OPENSSL_PATCH_VER=3.0.15 TEST_NGINX_TIMEOUT=5 PCRE2_VER=10.42
66+
- 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
67+
- 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
6668
- 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
6769
- NGINX_VERSION=1.27.1 BORINGSSL=1 TEST_NGINX_USE_HTTP3=1 TEST_NGINX_QUIC_IDLE_TIMEOUT=3 PCRE2_VER=10.42
6870

src/ngx_http_lua_subrequest.c

-6
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,6 @@ ngx_http_lua_ngx_location_capture_multi(lua_State *L)
173173
return luaL_error(L, "no request object found");
174174
}
175175

176-
#if (NGX_HTTP_V2)
177-
if (r->main->stream) {
178-
return luaL_error(L, "http2 requests not supported yet");
179-
}
180-
#endif
181-
182176
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
183177
if (ctx == NULL) {
184178
return luaL_error(L, "no ctx found");

t/005-exit.t

+5
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ GET /api?user=agentz
124124
125125
=== TEST 6: working with ngx_auth_request (simplest form, w/o ngx_memc)
126126
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
127+
--- no_http2
127128
--- http_config eval
128129
"
129130
lua_package_cpath '$::LuaCpath';
@@ -197,6 +198,7 @@ Logged in 56
197198
198199
=== TEST 7: working with ngx_auth_request (simplest form)
199200
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
201+
--- no_http2
200202
--- http_config eval
201203
"
202204
lua_package_cpath '$::LuaCpath';
@@ -269,6 +271,7 @@ Logged in 56
269271
270272
271273
=== TEST 8: working with ngx_auth_request
274+
--- no_http2
272275
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
273276
--- http_config eval
274277
"
@@ -762,6 +765,7 @@ GET /t
762765
763766
764767
=== TEST 27: accepts NGX_ERROR
768+
--- no_http2
765769
--- config
766770
location = /t {
767771
content_by_lua_block {
@@ -780,6 +784,7 @@ curl: (95) HTTP/3 stream 0 reset by server
780784
781785
782786
=== TEST 28: accepts NGX_DECLINED
787+
--- no_http2
783788
--- config
784789
location = /t {
785790
content_by_lua_block {

t/014-bugs.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2
201201
header field names MUST be converted to lowercase prior to their
202202
encoding in HTTP/2. A request or response containing uppercase
203203
header field names MUST be treated as malformed
204-
204+
--- no_http2
205205
--- config
206206
location /sub {
207207
content_by_lua '

t/016-resp-header.t

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ Fooy: cony1, cony2
298298
299299
300300
=== TEST 15: set header after ngx.print
301+
--- no_http2
301302
--- config
302303
location /lua {
303304
default_type "text/plain";

t/020-subrequest.t

+1
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,7 @@ body:
11981198
11991199
12001200
=== TEST 43: subrequests with an output body filter returning NGX_ERROR
1201+
--- no_http2
12011202
--- config
12021203
location /sub {
12031204
echo hello world;

t/023-rewrite/exit.t

+3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ GET /api?user=agentz
120120
121121
122122
=== TEST 6: working with ngx_auth_request (simplest form, w/o ngx_memc)
123+
--- no_http2
123124
--- http_config eval
124125
"
125126
lua_package_cpath '$::LuaCpath';
@@ -192,6 +193,7 @@ Logged in 56
192193
193194
194195
=== TEST 7: working with ngx_auth_request (simplest form)
196+
--- no_http2
195197
--- http_config eval
196198
"
197199
lua_package_cpath '$::LuaCpath';
@@ -264,6 +266,7 @@ Logged in 56
264266
265267
266268
=== TEST 8: working with ngx_auth_request
269+
--- no_http2
267270
--- http_config eval
268271
"
269272
lua_package_cpath '$::LuaCpath';

t/024-access/exit.t

+3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ GET /api?user=agentz
114114
115115
116116
=== TEST 6: working with ngx_auth_request (simplest form, w/o ngx_memc)
117+
--- no_http2
117118
--- http_config eval
118119
"
119120
lua_package_cpath '$::LuaCpath';
@@ -182,6 +183,7 @@ Logged in 56
182183
183184
184185
=== TEST 7: working with ngx_auth_request (simplest form)
186+
--- no_http2
185187
--- http_config eval
186188
"
187189
lua_package_cpath '$::LuaCpath';
@@ -249,6 +251,7 @@ Logged in 56
249251
250252
251253
=== TEST 8: working with ngx_auth_request
254+
--- no_http2
252255
--- http_config eval
253256
"
254257
lua_package_cpath '$::LuaCpath';

t/026-mysql.t

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ run_tests();
1616
__DATA__
1717

1818
=== TEST 1: when mysql query timed out, kill that query by Lua
19+
--- no_http2
1920
--- http_config
2021
upstream backend {
2122
drizzle_server 127.0.0.1:$TEST_NGINX_MYSQL_PORT protocol=mysql

t/033-ctx.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ GET /t
279279
--- error_log
280280
ngx.ctx = 32
281281
--- curl_error eval
282-
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/
282+
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/
283283

284284

285285

t/041-header-filter.t

+24-22
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ GET /read
125125
--- error_code
126126
--- response_body
127127
--- curl_error eval
128-
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/
128+
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/
129129

130130

131131

@@ -449,6 +449,7 @@ GET /lua
449449

450450

451451
=== TEST 21: lua error (string)
452+
--- no_http2
452453
--- config
453454
location /lua {
454455
set $foo '';
@@ -468,11 +469,12 @@ failed to run header_filter_by_lua*: header_filter_by_lua(nginx.conf:47):2: Some
468469
--- no_error_log
469470
[alert]
470471
--- curl_error eval
471-
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/
472+
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/
472473

473474

474475

475476
=== TEST 22: lua error (nil)
477+
--- no_http2
476478
--- config
477479
location /lua {
478480
set $foo '';
@@ -492,7 +494,7 @@ failed to run header_filter_by_lua*: unknown reason
492494
--- no_error_log
493495
[alert]
494496
--- curl_error eval
495-
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/
497+
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/
496498

497499

498500

@@ -508,7 +510,7 @@ GET /lua
508510
--- error_log
509511
API disabled in the context of header_filter_by_lua*
510512
--- curl_error eval
511-
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/
513+
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/
512514

513515

514516

@@ -524,7 +526,7 @@ GET /lua
524526
--- error_log
525527
API disabled in the context of header_filter_by_lua*
526528
--- curl_error eval
527-
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/
529+
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/
528530

529531

530532

@@ -540,7 +542,7 @@ GET /lua
540542
--- error_log
541543
API disabled in the context of header_filter_by_lua*
542544
--- curl_error eval
543-
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/
545+
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/
544546

545547

546548

@@ -556,7 +558,7 @@ GET /lua
556558
--- error_log
557559
API disabled in the context of header_filter_by_lua*
558560
--- curl_error eval
559-
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/
561+
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/
560562

561563

562564

@@ -572,7 +574,7 @@ GET /lua
572574
--- error_log
573575
API disabled in the context of header_filter_by_lua*
574576
--- curl_error eval
575-
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/
577+
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/
576578

577579

578580

@@ -592,7 +594,7 @@ GET /lua
592594
--- error_log
593595
API disabled in the context of header_filter_by_lua*
594596
--- curl_error eval
595-
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/
597+
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/
596598

597599

598600

@@ -612,7 +614,7 @@ GET /lua
612614
--- error_log
613615
API disabled in the context of header_filter_by_lua*
614616
--- curl_error eval
615-
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/
617+
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/
616618

617619

618620

@@ -628,7 +630,7 @@ GET /lua
628630
--- error_log
629631
API disabled in the context of header_filter_by_lua*
630632
--- curl_error eval
631-
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/
633+
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/
632634

633635

634636

@@ -644,7 +646,7 @@ GET /lua
644646
--- error_log
645647
API disabled in the context of header_filter_by_lua*
646648
--- curl_error eval
647-
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/
649+
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/
648650

649651

650652

@@ -660,7 +662,7 @@ GET /lua
660662
--- error_log
661663
API disabled in the context of header_filter_by_lua*
662664
--- curl_error eval
663-
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/
665+
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/
664666

665667

666668

@@ -694,7 +696,7 @@ GET /lua
694696
--- error_log eval
695697
qr/API disabled in the context of header_filter_by_lua\*|http3 requests are not supported without content-length header/ms
696698
--- curl_error eval
697-
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/
699+
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/
698700

699701

700702

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

719721
$err_log;
720722
--- curl_error eval
721-
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/
723+
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/
722724

723725

724726

@@ -734,7 +736,7 @@ GET /lua
734736
--- error_log
735737
API disabled in the context of header_filter_by_lua*
736738
--- curl_error eval
737-
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/
739+
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/
738740

739741

740742

@@ -750,7 +752,7 @@ GET /lua
750752
--- error_log
751753
API disabled in the context of header_filter_by_lua*
752754
--- curl_error eval
753-
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/
755+
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/
754756

755757

756758

@@ -799,7 +801,7 @@ in function 'error'
799801
in function 'bar'
800802
in function 'foo'
801803
--- curl_error eval
802-
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/
804+
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/
803805

804806

805807

@@ -819,7 +821,7 @@ GET /lua?a=1&b=2
819821
--- error_log eval
820822
qr/failed to load external Lua file ".*?test2\.lua": cannot open .*? No such file or directory/
821823
--- curl_error eval
822-
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/
824+
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/
823825

824826

825827

@@ -867,7 +869,7 @@ failed to load inlined Lua code: header_filter_by_lua(nginx.conf:41):2: unexpect
867869
--- no_error_log
868870
no_such_error
869871
--- curl_error eval
870-
qr/curl: \(56\) Failure when receiving data from the peer/
872+
qr/curl: \(56\) Failure when receiving data from the peer|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly: INTERNAL_ERROR \(err 2\)/
871873
872874
873875
@@ -898,7 +900,7 @@ failed to load inlined Lua code: header_filter_by_lua(nginx.conf:49):2: unexpect
898900
--- no_error_log
899901
no_such_error
900902
--- curl_error eval
901-
qr/curl: \(56\) Failure when receiving data from the peer/
903+
qr/curl: \(56\) Failure when receiving data from the peer|curl: \(92\) HTTP\/2 stream 1 was not closed cleanly: INTERNAL_ERROR \(err 2\)/
902904
903905
904906
@@ -924,4 +926,4 @@ failed to load inlined Lua code: header_filter_by_lua(...90123456789012345678901
924926
--- no_error_log
925927
[alert]
926928
--- curl_error eval
927-
qr/curl: \(56\) Failure when receiving data from the peer/
929+
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\)/

t/056-flush.t

+1-2
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ GET /test
516516
my @errlog;
517517
if (defined $ENV{TEST_NGINX_USE_HTTP2}) {
518518
@errlog = [
519-
qr/lua writes elapsed 0\.[7-9]\d+ sec/,
519+
qr/lua writes elapsed (?:0\.[7-9]\d+|[12]\.\d+) sec/,
520520
qr/lua flush requires waiting: buffered 0x[0-9a-f]+, delayed:1/,
521521
];
522522
} else {
@@ -526,7 +526,6 @@ qr/lua flush requires waiting: buffered 0x[0-9a-f]+, delayed:1/,
526526
];
527527
}
528528
@errlog;
529-
530529
--- no_error_log
531530
[error]
532531
--- timeout: 4

0 commit comments

Comments
 (0)