Skip to content

Commit

Permalink
fix(proxy-wasm) execute the whole filter chain when dispatching HTTP …
Browse files Browse the repository at this point in the history
…calls
  • Loading branch information
casimiro committed Oct 4, 2023
1 parent e2705a0 commit d196906
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/http/proxy_wasm/ngx_http_proxy_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ ngx_http_proxy_wasm_on_request_body_handler(ngx_http_request_t *r)
rc = ngx_proxy_wasm_resume(pwctx, pwctx->phase,
NGX_PROXY_WASM_STEP_REQ_BODY);
if (rc == NGX_AGAIN) {
ngx_proxy_wasm_ctx_reset_chain(pwctx);
ngx_wasm_yield(&rctx->env);
}
}
Expand Down
110 changes: 76 additions & 34 deletions t/03-proxy_wasm/hfuncs/130-proxy_dispatch_http.t
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,49 @@ Hello back
=== TEST 18: proxy_wasm - dispatch_http_call() sanity unix domain socket
=== TEST 18: proxy_wasm - dispatch_http_call() on_request_body, chained filters
All response phases are invoked on chained filters.
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
location /dispatched {
return 200 "Hello back";
}
location /t {
proxy_wasm hostcalls 'on=request_body \
test=/t/dispatch_http_call \
host=127.0.0.1:$TEST_NGINX_SERVER_PORT \
path=/dispatched';
proxy_wasm hostcalls;
echo ok;
}
--- request
GET /t
Hello world
--- response_body
ok
--- grep_error_log eval: qr/\[info\] .*? on_(http_call_response|response|log|done).*/
--- grep_error_log_out eval
qr/\A.* on_http_call_response \(id: 0, status: 200, headers: 5, body_bytes: 10, trailers: 0, op: \).*
.* on_response_headers.*
.* on_response_headers.*
.* on_response_body.*
.* on_response_body.*
.* on_response_body.*
.* on_response_body.*
.* on_done.*
.* on_log.*
.* on_done.*
.* on_log.*\Z/
--- no_error_log
[error]
=== TEST 19: proxy_wasm - dispatch_http_call() sanity unix domain socket
:authority set to "localhost"
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -376,7 +418,7 @@ Host: localhost\s*
=== TEST 19: proxy_wasm - dispatch_http_call() sanity resolver + hostname (IPv4), default port
=== TEST 20: proxy_wasm - dispatch_http_call() sanity resolver + hostname (IPv4), default port
Needs IPv4 resolution + external I/O to succeed.
Succeeds on:
- HTTP 200 (httpbin.org/headers success)
Expand Down Expand Up @@ -410,7 +452,7 @@ qq{
=== TEST 20: proxy_wasm - dispatch_http_call() sanity resolver + hostname (IPv6), default port
=== TEST 21: proxy_wasm - dispatch_http_call() sanity resolver + hostname (IPv6), default port
Disabled on GitHub Actions due to IPv6 constraint.
--- skip_eval: 4: system("ping6 -c 1 ::1 >/dev/null 2>&1") ne 0 || defined $ENV{GITHUB_ACTIONS}
--- timeout eval: $::ExtTimeout
Expand All @@ -437,7 +479,7 @@ qq{
=== TEST 21: proxy_wasm - dispatch_http_call() sanity resolver + hostname (IPv4) + port
=== TEST 22: proxy_wasm - dispatch_http_call() sanity resolver + hostname (IPv4) + port
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- http_config
Expand Down Expand Up @@ -474,7 +516,7 @@ qq{
=== TEST 22: proxy_wasm - dispatch_http_call() resolver error (host not found)
=== TEST 23: proxy_wasm - dispatch_http_call() resolver error (host not found)
--- timeout eval: $::ExtTimeout
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand All @@ -498,7 +540,7 @@ qr/(\[error\]|Uncaught RuntimeError|\s+).*?dispatch failed: tcp socket - resolve
=== TEST 23: proxy_wasm - dispatch_http_call() sanity IP + port (IPv4)
=== TEST 24: proxy_wasm - dispatch_http_call() sanity IP + port (IPv4)
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -521,7 +563,7 @@ ok
=== TEST 24: proxy_wasm - dispatch_http_call() sanity IP + port (IPv6)
=== TEST 25: proxy_wasm - dispatch_http_call() sanity IP + port (IPv6)
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -546,7 +588,7 @@ ok
=== TEST 25: proxy_wasm - dispatch_http_call() :authority overrides Host with TCP/IP
=== TEST 26: proxy_wasm - dispatch_http_call() :authority overrides Host with TCP/IP
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- http_config
Expand Down Expand Up @@ -580,7 +622,7 @@ qq{
=== TEST 26: proxy_wasm - dispatch_http_call() :authority overrides Host with unix domain socket
=== TEST 27: proxy_wasm - dispatch_http_call() :authority overrides Host with unix domain socket
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- http_config eval
Expand Down Expand Up @@ -618,7 +660,7 @@ qq{
=== TEST 27: proxy_wasm - dispatch_http_call() many request headers (> 10)
=== TEST 28: proxy_wasm - dispatch_http_call() many request headers (> 10)
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand Down Expand Up @@ -656,7 +698,7 @@ K: 11.*
=== TEST 28: proxy_wasm - dispatch_http_call() empty response body (HTTP 204)
=== TEST 29: proxy_wasm - dispatch_http_call() empty response body (HTTP 204)
--- skip_no_debug: 4
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -685,7 +727,7 @@ tcp socket closing
=== TEST 29: proxy_wasm - dispatch_http_call() empty response body (Content-Length: 0)
=== TEST 30: proxy_wasm - dispatch_http_call() empty response body (Content-Length: 0)
--- skip_no_debug: 4
--- load_nginx_modules: ngx_http_echo_module ngx_http_headers_more_filter_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -713,7 +755,7 @@ tcp socket closing
=== TEST 30: proxy_wasm - dispatch_http_call() no response body (HEAD)
=== TEST 31: proxy_wasm - dispatch_http_call() no response body (HEAD)
--- skip_no_debug: 4
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -743,7 +785,7 @@ tcp socket closing
=== TEST 31: proxy_wasm - dispatch_http_call() "Content-Length" response body
=== TEST 32: proxy_wasm - dispatch_http_call() "Content-Length" response body
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -766,7 +808,7 @@ Hello world
=== TEST 32: proxy_wasm - dispatch_http_call() "Transfer-Encoding: chunked" response body
=== TEST 33: proxy_wasm - dispatch_http_call() "Transfer-Encoding: chunked" response body
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -791,7 +833,7 @@ Content-Length: 0.*
=== TEST 33: proxy_wasm - dispatch_http_call() large response
=== TEST 34: proxy_wasm - dispatch_http_call() large response
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -817,7 +859,7 @@ Content-Length: 0.*
=== TEST 34: proxy_wasm - dispatch_http_call() small wasm_socket_buffer_size
=== TEST 35: proxy_wasm - dispatch_http_call() small wasm_socket_buffer_size
--- skip_no_debug: 4
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -845,7 +887,7 @@ tcp socket trying to receive data (max: 1)
=== TEST 35: proxy_wasm - dispatch_http_call() small wasm_socket_large_buffers
=== TEST 36: proxy_wasm - dispatch_http_call() small wasm_socket_large_buffers
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -872,7 +914,7 @@ Hello world
=== TEST 36: proxy_wasm - dispatch_http_call() too small wasm_socket_large_buffers
=== TEST 37: proxy_wasm - dispatch_http_call() too small wasm_socket_large_buffers
--- skip_no_debug: 4
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -900,7 +942,7 @@ tcp socket - upstream response headers too large, increase wasm_socket_large_buf
=== TEST 37: proxy_wasm - dispatch_http_call() too small wasm_socket_large_buffers size
=== TEST 38: proxy_wasm - dispatch_http_call() too small wasm_socket_large_buffers size
--- skip_no_debug: 4
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -928,7 +970,7 @@ tcp socket - upstream response headers too large, increase wasm_socket_large_buf
=== TEST 38: proxy_wasm - dispatch_http_call() not enough wasm_socket_large_buffers
=== TEST 39: proxy_wasm - dispatch_http_call() not enough wasm_socket_large_buffers
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- tcp_listen: 12345
Expand Down Expand Up @@ -959,7 +1001,7 @@ sub {
=== TEST 39: proxy_wasm - dispatch_http_call() scarce wasm_socket_large_buffers
=== TEST 40: proxy_wasm - dispatch_http_call() scarce wasm_socket_large_buffers
--- skip_no_debug: 4
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -987,7 +1029,7 @@ tcp socket trying to receive data (max: 1023)
=== TEST 40: proxy_wasm - dispatch_http_call() TCP reader error
=== TEST 41: proxy_wasm - dispatch_http_call() TCP reader error
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- tcp_listen: 12345
Expand All @@ -1011,7 +1053,7 @@ qr/(\[error\]|Uncaught RuntimeError|\s+).*?dispatch failed: tcp socket - parser
=== TEST 41: proxy_wasm - dispatch_http_call() re-entrant after status line
=== TEST 42: proxy_wasm - dispatch_http_call() re-entrant after status line
--- skip_no_debug: 4
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -1039,7 +1081,7 @@ tcp socket trying to receive data (max: 1017)
=== TEST 42: proxy_wasm - dispatch_http_call() trap in dispatch handler
=== TEST 43: proxy_wasm - dispatch_http_call() trap in dispatch handler
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -1064,7 +1106,7 @@ tcp socket trying to receive data (max: 1017)
=== TEST 43: proxy_wasm - dispatch_http_call() invalid response headers
=== TEST 44: proxy_wasm - dispatch_http_call() invalid response headers
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- tcp_listen: 12345
Expand All @@ -1090,7 +1132,7 @@ qr/(\[error\]|Uncaught RuntimeError|\s+).*?dispatch failed: tcp socket - parser
=== TEST 44: proxy_wasm - dispatch_http_call() async dispatch x2
=== TEST 45: proxy_wasm - dispatch_http_call() async dispatch x2
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand Down Expand Up @@ -1138,7 +1180,7 @@ qr/(\[error\]|Uncaught RuntimeError|\s+).*?dispatch failed: tcp socket - parser
=== TEST 45: proxy_wasm - dispatch_http_call() can be chained by different filters
=== TEST 46: proxy_wasm - dispatch_http_call() can be chained by different filters
So long as these filters do not produce content.
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down Expand Up @@ -1171,7 +1213,7 @@ qr/^\*\d+ .*? on_http_call_response \(id: \d+[^*]*
=== TEST 46: proxy_wasm - dispatch_http_call() on log step
=== TEST 47: proxy_wasm - dispatch_http_call() on log step
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -1195,7 +1237,7 @@ qr/(\[error\]|Uncaught RuntimeError|\s+).*?dispatch failed: bad step/
=== TEST 47: proxy_wasm - dispatch_http_call() supports get_http_call_response_headers()
=== TEST 48: proxy_wasm - dispatch_http_call() supports get_http_call_response_headers()
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -1219,7 +1261,7 @@ X-Callout-Header: callout-header-value
=== TEST 48: proxy_wasm - dispatch_http_call() get :status dispatch response header
=== TEST 49: proxy_wasm - dispatch_http_call() get :status dispatch response header
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand Down Expand Up @@ -1262,7 +1304,7 @@ qr/^\*\d+ .*? on_http_call_response \(id: \d+, status: 200[^*]*
=== TEST 49: proxy_wasm - dispatch_http_call() with dispatched request body
=== TEST 50: proxy_wasm - dispatch_http_call() with dispatched request body
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -1288,7 +1330,7 @@ helloworld
=== TEST 50: proxy_wasm - dispatch_http_call() override Content-Length
=== TEST 51: proxy_wasm - dispatch_http_call() override Content-Length
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
--- config
Expand All @@ -1315,7 +1357,7 @@ helloworl
=== TEST 51: proxy_wasm - dispatch_http_call() cannot override hard-coded request headers
=== TEST 52: proxy_wasm - dispatch_http_call() cannot override hard-coded request headers
--- skip_no_debug: 4
--- load_nginx_modules: ngx_http_echo_module
--- wasm_modules: hostcalls
Expand Down

0 comments on commit d196906

Please sign in to comment.