mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Squashed 'src/deps/src/lua-nginx-module/' changes from c47084b5d7..0e769b7643
0e769b7643 tests: 082-body-filter-2.t: skip this test if mockeagain is not loaded correctly. (#2275) 766b7a8add tests: use random ports instead of constant ports to prevent conflicts during testing. (#2274) bf5d9d3b5c change: don't move the expired item to the lru queue head when lookup. e8da8781c9 optimize: Make the use of NGX_PCRE2 clearer. f249fa9b7e bugfix: fixed memory leak in the case of connection in dubious. (#2270) 8c7f9bf46a tests: t/129-ssl-socket.t: use the same IP to ensure that the ssl session can be reused. (#2267) 0d054a57f4 tests: t/128-duplex-tcp-socket: replacing constant port 7658 with a random port. (#2268) ff96d75a49 tests: update openssl to 1.1.1w. 2d32c7c8d6 bumped version of lua-nginx-module to 10026. 75ab35d3c4 doc: add http2 and http3 limitation doc comment for ngx.req.socket API. 0c3675ff4d tests: adjust some test cases for HTTP3. 3a0b823d9f feature: make HTTP3 authority as http_host header. 577dfebba4 feature: add max_bytes argument for get_body_data() function. 339b08a4be doc: make some debug message and comments accurate. 187ad5c050 bugfix: failed to build when building without http2&http3 modules. 86bea01b24 changes: modify read body api limitation for HTTP/2 or HTTP/3 requests. db80075e0a doc: more accurate error messages. 7661f9b48a tests: t/166-ssl-client-hello.t: fixed test plan. 87f41a9545 bugfix: fix some failed test case. 25c9643cf4 docs: remove duplicated sentence. 51984aea04 tests: check if the version number has been specified before downloading OpenSSL. (#2240) 5ae767d504 tests: build drizzle with python3. 488ba27110 bugfix: failed to compile with clang. 028852c156 enable http3 test. c27df5c6ba tests: fixed test cases for http2 when running with TEST_NGINX_USE_HTTP2=1. (#62) 7c8a9d53e7 test3: more http3 tests fixes. 309edb6832 tests: fixed test for http3. 03ec7f1d71 bugfix: don't include pcre.h with PCRE2 used. 8e9c33a9ef tests: update t/cert/test.crl. 2448743b68 tests: update t/cert/test.crl. f29e8487b2 doc: update TODO list since tcpsock:bind is already implemented. cb83e33e26 feature: support pcre2 c89469e920 doc: update release date e2d0505955 doc: revise the description regarding Nginx compatibility. 25b7959b29 bugfix: fixed compilation error: variable 'nelts' set but not used. e69fd3de28 feature: upgrade nginx core to 1.25.1. f39e7e50fe change: remove ngx.re from ngx.run_worker_thread. caad24b355 doc: modified lua_ssl_certificate, lua_ssl_certificate_key and lua_ssl_trusted_certificate. 4ca27c48f5 Revert "feature: allow get empty key for ngx.req.get_uri()." 05da249316 feature: allow get empty key for ngx.req.get_uri(). b4c0450bbe feature: Support lua_ssl_certificate and lua_ssl_certificate_key. f5c2d36101 Merge branch 'v0.10.25' into master. bba3db08e7 bugfix: used after free when encountering invalid http IF-Match header. 592a91c1ab optimize: Optimized use of SSL contexts. 992cae739d doc: fixed typo. 28aced45f6 bugfix: ngx_http_lua_socket_tcp_bind is also allowed in ssl_session_fetch_by and ssl_client_hello_by. 64631297fb bugfix: ssl_client_hello_by_lua generating chunk cache key and chunk name c9a0808c89 bugfix: when value type is SHDICT_TNUMBER, then it should get the number field instead of the bool field. 0c3853e124 bugfix: mixed recv api call causes unexpected result. 4bf1b0b8d7 change: lua-ssl-protocols: Disabled SSLv3 and enable TLSv1.3 by default. c91fb13a8c doc: fix typo in the comment. 0090f3faf6 bugfix: disable http2 in body read due to http2 stream processing bug. bf8c91d111 doc: fixed typo in error messages. 16de4bea62 bugfix: Fix handling of new list elements. 39941d4c9a tests: add two more test cases for body_filter_by_lua*. git-subtree-dir: src/deps/src/lua-nginx-module git-subtree-split: 0e769b76432df91e5f10aa56a56858e8a190faf7
This commit is contained in:
parent
f7bc0d8720
commit
65e43ea606
144 changed files with 4195 additions and 723 deletions
60
.travis.yml
60
.travis.yml
|
|
@ -1,4 +1,4 @@
|
|||
dist: bionic
|
||||
dist: focal
|
||||
|
||||
branches:
|
||||
only:
|
||||
|
|
@ -24,6 +24,11 @@ addons:
|
|||
- libtest-longstring-perl
|
||||
- liblist-moreutils-perl
|
||||
- libgd-dev
|
||||
- time
|
||||
- cmake
|
||||
- libunwind-dev
|
||||
- wget
|
||||
- libbrotli1
|
||||
|
||||
cache:
|
||||
directories:
|
||||
|
|
@ -38,9 +43,13 @@ env:
|
|||
- LUAJIT_INC=$LUAJIT_PREFIX/include/luajit-2.1
|
||||
- LUA_INCLUDE_DIR=$LUAJIT_INC
|
||||
- PCRE_VER=8.45
|
||||
- PCRE2_VER=10.37
|
||||
- PCRE_PREFIX=/opt/pcre
|
||||
- PCRE2_PREFIX=/opt/pcre2
|
||||
- PCRE_LIB=$PCRE_PREFIX/lib
|
||||
- PCRE2_LIB=$PCRE2_PREFIX/lib
|
||||
- PCRE_INC=$PCRE_PREFIX/include
|
||||
- PCRE2_INC=$PCRE2_PREFIX/include
|
||||
- OPENSSL_PREFIX=/opt/ssl
|
||||
- OPENSSL_LIB=$OPENSSL_PREFIX/lib
|
||||
- OPENSSL_INC=$OPENSSL_PREFIX/include
|
||||
|
|
@ -50,9 +59,14 @@ env:
|
|||
- LD_LIBRARY_PATH=$LUAJIT_LIB:$LD_LIBRARY_PATH
|
||||
- DRIZZLE_VER=2011.07.21
|
||||
- TEST_NGINX_SLEEP=0.006
|
||||
- MALLOC_PERTURB_=9
|
||||
jobs:
|
||||
- NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.0l OPENSSL_PATCH_VER=1.1.0d
|
||||
- NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.1s OPENSSL_PATCH_VER=1.1.1f
|
||||
#- NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.0l OPENSSL_PATCH_VER=1.1.0d
|
||||
#- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.0l OPENSSL_PATCH_VER=1.1.0d
|
||||
- NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.1w OPENSSL_PATCH_VER=1.1.1f
|
||||
- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.1w OPENSSL_PATCH_VER=1.1.1f USE_PCRE2=Y
|
||||
- NGINX_VERSION=1.25.1 BORINGSSL=1 TEST_NGINX_USE_HTTP3=1 USE_PCRE2=Y
|
||||
#- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.1w TEST_NGINX_USE_HTTP2=1
|
||||
|
||||
services:
|
||||
- memcached
|
||||
|
|
@ -60,16 +74,18 @@ services:
|
|||
- mysql
|
||||
|
||||
before_install:
|
||||
- sudo apt update
|
||||
- sudo apt install --only-upgrade ca-certificates
|
||||
- '! grep -n -P ''(?<=.{80}).+'' --color `find src -name ''*.c''` `find . -name ''*.h''` || (echo "ERROR: Found C source lines exceeding 80 columns." > /dev/stderr; exit 1)'
|
||||
- '! grep -n -P ''\t+'' --color `find src -name ''*.c''` `find . -name ''*.h''` || (echo "ERROR: Cannot use tabs." > /dev/stderr; exit 1)'
|
||||
- /usr/bin/env perl $(command -v cpanm) --sudo --notest Test::Nginx IPC::Run > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- pyenv global 2.7
|
||||
|
||||
install:
|
||||
- if [ ! -f download-cache/drizzle7-$DRIZZLE_VER.tar.gz ]; then wget -P download-cache http://openresty.org/download/drizzle7-$DRIZZLE_VER.tar.gz; fi
|
||||
- if [ ! -f download-cache/pcre-$PCRE_VER.tar.gz ]; then wget -P download-cache https://downloads.sourceforge.net/project/pcre/pcre/${PCRE_VER}/pcre-${PCRE_VER}.tar.gz; fi
|
||||
- if [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -P download-cache https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz || wget -P download-cache https://www.openssl.org/source/old/${OPENSSL_VER//[a-z]/}/openssl-$OPENSSL_VER.tar.gz; fi
|
||||
- if [ ! -f download-cache/drizzle7-$DRIZZLE_VER.tar.gz ]; then wget -P download-cache https://github.com/openresty/openresty-deps-prebuild/releases/download/v20230902/drizzle7-$DRIZZLE_VER.tar.gz; fi
|
||||
- if [ "$USE_PCRE2" != "Y" ] && [ ! -f download-cache/pcre-$PCRE_VER.tar.gz ]; then wget -P download-cache https://downloads.sourceforge.net/project/pcre/pcre/${PCRE_VER}/pcre-${PCRE_VER}.tar.gz; fi
|
||||
- if [ "$USE_PCRE2" = "Y" ] && [ ! -f download-cache/pcre2-$PCRE2_VER.tar.gz ]; then wget -P download-cache https://downloads.sourceforge.net/project/pcre/pcre2/${PCRE2_VER}/pcre2-${PCRE2_VER}.tar.gz; fi
|
||||
- if [ -n "$OPENSSL_VER" ] && [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -P download-cache https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz || wget -P download-cache https://www.openssl.org/source/old/${OPENSSL_VER//[a-z]/}/openssl-$OPENSSL_VER.tar.gz; fi
|
||||
- if [ -n "$OPENSSL_VER" ] && [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -P download-cache https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz || wget -P download-cache https://www.openssl.org/source/old/${OPENSSL_VER//[a-z]/}/openssl-$OPENSSL_VER.tar.gz; fi
|
||||
- wget https://github.com/openresty/openresty-deps-prebuild/releases/download/v20230902/boringssl-20230902-x64-focal.tar.gz
|
||||
- wget https://github.com/openresty/openresty-deps-prebuild/releases/download/v20230902/curl-h3-x64-focal.tar.gz
|
||||
- git clone https://github.com/openresty/test-nginx.git
|
||||
- git clone https://github.com/openresty/openresty.git ../openresty
|
||||
- git clone https://github.com/openresty/no-pool-nginx.git ../no-pool-nginx
|
||||
|
|
@ -91,21 +107,24 @@ install:
|
|||
- git clone https://github.com/openresty/lua-resty-core.git ../lua-resty-core
|
||||
- git clone https://github.com/openresty/lua-resty-lrucache.git ../lua-resty-lrucache
|
||||
- git clone https://github.com/openresty/lua-resty-mysql.git ../lua-resty-mysql
|
||||
- git clone https://github.com/spacewander/lua-resty-rsa.git ../lua-resty-rsa
|
||||
- git clone https://github.com/openresty/lua-resty-string.git ../lua-resty-string
|
||||
- git clone https://github.com/openresty/stream-lua-nginx-module.git ../stream-lua-nginx-module
|
||||
- git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git luajit2
|
||||
|
||||
before_script:
|
||||
- mysql -uroot -e 'create database ngx_test; grant all on ngx_test.* to "ngx_test"@"%" identified by "ngx_test"; flush privileges;'
|
||||
- mysql -uroot -e "create database ngx_test; CREATE USER 'ngx_test'@'%' IDENTIFIED WITH mysql_native_password BY 'ngx_test'; grant all on ngx_test.* to 'ngx_test'@'%'; flush privileges;"
|
||||
|
||||
script:
|
||||
- export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH
|
||||
- sudo tar -C / -xf curl-h3-x64-focal.tar.gz
|
||||
- export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:/opt/curl-h3/bin:$PATH
|
||||
- ngx-releng > check.txt || true
|
||||
- lines=`wc -l check.txt | awk '{print $1}'`; if [ $lines -gt 5 ]; then cat check.txt; exit 1; fi
|
||||
- sudo iptables -I OUTPUT 1 -p udp --dport 10086 -j REJECT
|
||||
- sudo iptables -I OUTPUT -p tcp --dst 127.0.0.2 --dport 12345 -j DROP
|
||||
- sudo iptables -I OUTPUT -p udp --dst 127.0.0.2 --dport 12345 -j DROP
|
||||
- sudo ip route add prohibit 0.0.0.1/32
|
||||
- sudo sysctl -w kernel.pid_max=10000
|
||||
- cd luajit2/
|
||||
- make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT -msse4.2' > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- sudo make install PREFIX=$LUAJIT_PREFIX > build.log 2>&1 || (cat build.log && exit 1)
|
||||
|
|
@ -116,19 +135,10 @@ script:
|
|||
- sudo make install-libdrizzle-1.0 > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- cd ../mockeagain/ && make CC=$CC -j$JOBS && cd ..
|
||||
- cd lua-cjson/ && make -j$JOBS && sudo make install && cd ..
|
||||
- tar zxf download-cache/pcre-$PCRE_VER.tar.gz
|
||||
- cd pcre-$PCRE_VER/
|
||||
- ./configure --prefix=$PCRE_PREFIX --enable-jit --enable-utf --enable-unicode-properties > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- sudo PATH=$PATH make install > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- cd ..
|
||||
- tar zxf download-cache/openssl-$OPENSSL_VER.tar.gz
|
||||
- cd openssl-$OPENSSL_VER/
|
||||
- patch -p1 < ../../openresty/patches/openssl-$OPENSSL_PATCH_VER-sess_set_get_cb_yield.patch
|
||||
- ./config shared enable-ssl3 enable-ssl3-method -g --prefix=$OPENSSL_PREFIX -DPURIFY > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- sudo make PATH=$PATH install_sw > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- cd ..
|
||||
- if [ "$USE_PCRE2" != "Y" ]; then tar zxf download-cache/pcre-$PCRE_VER.tar.gz; cd pcre-$PCRE_VER/; ./configure --prefix=$PCRE_PREFIX --enable-jit --enable-utf --enable-unicode-properties > build.log 2>&1 || (cat build.log && exit 1); make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1); sudo PATH=$PATH make install > build.log 2>&1 || (cat build.log && exit 1); cd ..; fi
|
||||
- if [ "$USE_PCRE2" = "Y" ]; then tar zxf download-cache/pcre2-$PCRE2_VER.tar.gz; cd pcre2-$PCRE2_VER/; ./configure --prefix=$PCRE2_PREFIX --enable-jit --enable-utf > build.log 2>&1 || (cat build.log && exit 1); make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1); sudo PATH=$PATH make install > build.log 2>&1 || (cat build.log && exit 1); cd ..; fi
|
||||
- if [ -n "$OPENSSL_VER" ]; then tar zxf download-cache/openssl-$OPENSSL_VER.tar.gz; cd openssl-$OPENSSL_VER/; patch -p1 < ../../openresty/patches/openssl-$OPENSSL_PATCH_VER-sess_set_get_cb_yield.patch; ./config shared enable-ssl3 enable-ssl3-method -g --prefix=$OPENSSL_PREFIX -DPURIFY > build.log 2>&1 || (cat build.log && exit 1); make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1); sudo make PATH=$PATH install_sw > build.log 2>&1 || (cat build.log && exit 1); cd ..; fi
|
||||
- if [ -n "$BORINGSSL" ]; then sudo mkdir -p /opt/ssl && sudo tar -C /opt/ssl -xf boringssl-20230902-x64-focal.tar.gz --strip-components=1; fi
|
||||
- export NGX_BUILD_CC=$CC
|
||||
- sh util/build-without-ssl.sh $NGINX_VERSION > build.log 2>&1 || (cat build.log && exit 1)
|
||||
- sh util/build-with-dd.sh $NGINX_VERSION > build.log 2>&1 || (cat build.log && exit 1)
|
||||
|
|
@ -139,6 +149,8 @@ script:
|
|||
- ldd `which nginx`|grep -E 'luajit|ssl|pcre'
|
||||
- export LD_PRELOAD=$PWD/mockeagain/mockeagain.so
|
||||
- export LD_LIBRARY_PATH=$PWD/mockeagain:$LD_LIBRARY_PATH
|
||||
- export TEST_NGINX_HTTP3_CRT=$PWD/t/cert/http3/http3.crt
|
||||
- export TEST_NGINX_HTTP3_KEY=$PWD/t/cert/http3/http3.key
|
||||
- export TEST_NGINX_RESOLVER=8.8.4.4
|
||||
- dig +short myip.opendns.com @resolver1.opendns.com || exit 0
|
||||
- dig +short @$TEST_NGINX_RESOLVER openresty.org || exit 0
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@ Name
|
|||
ngx_http_lua_module - Embed the power of Lua into Nginx HTTP Servers.
|
||||
|
||||
This module is a core component of [OpenResty](https://openresty.org). If you are using this module,
|
||||
then you are essentially using OpenResty.
|
||||
then you are essentially using OpenResty :)
|
||||
|
||||
*This module is not distributed with the Nginx source.* See
|
||||
[the installation instructions](#installation).
|
||||
|
||||
This is a core component of OpenResty. If you are using this module, then you are essentially using OpenResty :)
|
||||
|
||||
Table of Contents
|
||||
=================
|
||||
|
||||
|
|
@ -65,8 +63,8 @@ Version
|
|||
=======
|
||||
|
||||
This document describes ngx_lua
|
||||
[v0.10.19](https://github.com/openresty/lua-nginx-module/tags), which was released
|
||||
on 3 Nov, 2020.
|
||||
[v0.10.25](https://github.com/openresty/lua-nginx-module/tags), which was released
|
||||
on 19 June 2023.
|
||||
|
||||
Videos
|
||||
======
|
||||
|
|
@ -309,6 +307,8 @@ Nginx Compatibility
|
|||
|
||||
The latest version of this module is compatible with the following versions of Nginx:
|
||||
|
||||
* 1.25.x (last tested: 1.25.1)
|
||||
* 1.21.x (last tested: 1.21.4)
|
||||
* 1.19.x (last tested: 1.19.3)
|
||||
* 1.17.x (last tested: 1.17.8)
|
||||
* 1.15.x (last tested: 1.15.8)
|
||||
|
|
@ -964,7 +964,6 @@ TODO
|
|||
|
||||
* cosocket: implement LuaSocket's unconnected UDP API.
|
||||
* cosocket: add support in the context of [init_by_lua*](#init_by_lua).
|
||||
* cosocket: implement the `bind()` method for stream-typed cosockets.
|
||||
* cosocket: review and merge aviramc's [patch](https://github.com/openresty/lua-nginx-module/pull/290) for adding the `bsdrecv` method.
|
||||
* cosocket: add configure options for different strategies of handling the cosocket connection exceeding in the pools.
|
||||
* review and apply vadim-pavlov's patch for [ngx.location.capture](#ngxlocationcapture)'s `extra_headers` option
|
||||
|
|
@ -1166,6 +1165,8 @@ Directives
|
|||
* [lua_ssl_ciphers](#lua_ssl_ciphers)
|
||||
* [lua_ssl_crl](#lua_ssl_crl)
|
||||
* [lua_ssl_protocols](#lua_ssl_protocols)
|
||||
* [lua_ssl_certificate](#lua_ssl_certificate)
|
||||
* [lua_ssl_certificate_key](#lua_ssl_certificate_key)
|
||||
* [lua_ssl_trusted_certificate](#lua_ssl_trusted_certificate)
|
||||
* [lua_ssl_verify_depth](#lua_ssl_verify_depth)
|
||||
* [lua_ssl_conf_command](#lua_ssl_conf_command)
|
||||
|
|
@ -2721,6 +2722,8 @@ lua_need_request_body
|
|||
|
||||
**phase:** *depends on usage*
|
||||
|
||||
Due to the stream processing feature of HTTP/2 or HTTP/3, this configuration could potentially block the entire request. Therefore, this configuration is effective only when HTTP/2 or HTTP/3 requests send content-length header. For requests with versions lower than HTTP/2, this configuration can still be used without any problems.
|
||||
|
||||
Determines whether to force the request body data to be read before running rewrite/access/content_by_lua* or not. The Nginx core does not read the client request body by default and if request body data is required, then this directive should be turned `on` or the [ngx.req.read_body](#ngxreqread_body) function should be called within the Lua code.
|
||||
|
||||
To read the request body data within the [$request_body](http://nginx.org/en/docs/http/ngx_http_core_module.html#var_request_body) variable,
|
||||
|
|
@ -3321,24 +3324,63 @@ lua_ssl_protocols
|
|||
|
||||
**syntax:** *lua_ssl_protocols \[SSLv2\] \[SSLv3\] \[TLSv1\] [TLSv1.1] [TLSv1.2] [TLSv1.3]*
|
||||
|
||||
**default:** *lua_ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2*
|
||||
**default:** *lua_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3*
|
||||
|
||||
**context:** *http, server, location*
|
||||
|
||||
Enables the specified protocols for requests to a SSL/TLS server in the [tcpsock:sslhandshake](#tcpsocksslhandshake) method.
|
||||
|
||||
The support for the `TLSv1.3` parameter requires version `v0.10.12` *and* OpenSSL 1.1.1.
|
||||
From version v0.10.25, the default value change from `SSLV3 TLSv1 TLSv1.1 TLSv1.2` to `TLSv1 TLSv1.1 TLSv1.2 TLSv1.3`.
|
||||
|
||||
This directive was first introduced in the `v0.9.11` release.
|
||||
|
||||
[Back to TOC](#directives)
|
||||
|
||||
lua_ssl_certificate
|
||||
-------------------
|
||||
|
||||
**syntax:** *lua_ssl_certificate <file>*
|
||||
|
||||
**default:** *none*
|
||||
|
||||
**context:** *http, server, location*
|
||||
|
||||
Specifies the file path to the SSL/TLS certificate in PEM format used for the [tcpsock:sslhandshake](#tcpsocksslhandshake) method.
|
||||
|
||||
This directive allows you to specify the SSL/TLS certificate that will be presented to server during the SSL/TLS handshake process.
|
||||
|
||||
This directive was first introduced in the `v0.10.26` release.
|
||||
|
||||
See also [lua_ssl_certificate_key](#lua_ssl_certificate_key) and [lua_ssl_verify_depth](#lua_ssl_verify_depth).
|
||||
|
||||
[Back to TOC](#directives)
|
||||
|
||||
lua_ssl_certificate_key
|
||||
-----------------------
|
||||
|
||||
**syntax:** *lua_ssl_certificate_key <file>*
|
||||
|
||||
**default:** *none*
|
||||
|
||||
**context:** *http, server, location*
|
||||
|
||||
Specifies the file path to the private key associated with the SSL/TLS certificate used in the [tcpsock:sslhandshake](#tcpsocksslhandshake) method.
|
||||
|
||||
This directive allows you to specify the private key file corresponding to the SSL/TLS certificate specified by lua_ssl_certificate. The private key should be in PEM format and must match the certificate.
|
||||
|
||||
This directive was first introduced in the `v0.10.26` release.
|
||||
|
||||
See also [lua_ssl_certificate](#lua_ssl_certificate) and [lua_ssl_verify_depth](#lua_ssl_verify_depth).
|
||||
|
||||
[Back to TOC](#directives)
|
||||
|
||||
lua_ssl_trusted_certificate
|
||||
---------------------------
|
||||
|
||||
**syntax:** *lua_ssl_trusted_certificate <file>*
|
||||
|
||||
**default:** *no*
|
||||
**default:** *none*
|
||||
|
||||
**context:** *http, server, location*
|
||||
|
||||
|
|
@ -3363,7 +3405,7 @@ Sets the verification depth in the server certificates chain.
|
|||
|
||||
This directive was first introduced in the `v0.9.11` release.
|
||||
|
||||
See also [lua_ssl_trusted_certificate](#lua_ssl_trusted_certificate).
|
||||
See also [lua_ssl_certificate](#lua_ssl_certificate), [lua_ssl_certificate_key](#lua_ssl_certificate_key) and [lua_ssl_trusted_certificate](#lua_ssl_trusted_certificate).
|
||||
|
||||
[Back to TOC](#directives)
|
||||
|
||||
|
|
@ -5384,6 +5426,8 @@ Reads the client request body synchronously without blocking the Nginx event loo
|
|||
local args = ngx.req.get_post_args()
|
||||
```
|
||||
|
||||
Due to the stream processing feature of HTTP/2 or HTTP/3, this api could potentially block the entire request. Therefore, this api is effective only when HTTP/2 or HTTP/3 requests send content-length header. For requests with versions lower than HTTP/2, this api can still be used without any problems.
|
||||
|
||||
If the request body is already read previously by turning on [lua_need_request_body](#lua_need_request_body) or by using other modules, then this function does not run and returns immediately.
|
||||
|
||||
If the request body has already been explicitly discarded, either by the [ngx.req.discard_body](#ngxreqdiscard_body) function or other modules, this function does not run and returns immediately.
|
||||
|
|
@ -5423,12 +5467,14 @@ See also [ngx.req.read_body](#ngxreqread_body).
|
|||
ngx.req.get_body_data
|
||||
---------------------
|
||||
|
||||
**syntax:** *data = ngx.req.get_body_data()*
|
||||
**syntax:** *data = ngx.req.get_body_data(max_bytes?)*
|
||||
|
||||
**context:** *rewrite_by_lua*, access_by_lua*, content_by_lua*, log_by_lua**
|
||||
|
||||
Retrieves in-memory request body data. It returns a Lua string rather than a Lua table holding all the parsed query arguments. Use the [ngx.req.get_post_args](#ngxreqget_post_args) function instead if a Lua table is required.
|
||||
|
||||
The optional `max_bytes` argument can be used when you don't need the entire body.
|
||||
|
||||
This function returns `nil` if
|
||||
|
||||
1. the request body has not been read,
|
||||
|
|
@ -5597,6 +5643,8 @@ Returns a read-only cosocket object that wraps the downstream connection. Only [
|
|||
|
||||
In case of error, `nil` will be returned as well as a string describing the error.
|
||||
|
||||
Due to the streaming nature of HTTP2 and HTTP3, this API cannot be used when the downstream connection is HTTP2 and HTTP3.
|
||||
|
||||
The socket object returned by this method is usually used to read the current request's body in a streaming fashion. Do not turn on the [lua_need_request_body](#lua_need_request_body) directive, and do not mix this call with [ngx.req.read_body](#ngxreqread_body) and [ngx.req.discard_body](#ngxreqdiscard_body).
|
||||
|
||||
If any request body data has been pre-read into the Nginx core request header buffer, the resulting cosocket object will take care of this to avoid potential data loss resulting from such pre-reading.
|
||||
|
|
@ -9321,12 +9369,6 @@ Only the following ngx_lua APIs could be used in `function_name` function of the
|
|||
* `ngx.decode_args`
|
||||
* `ngx.quote_sql_str`
|
||||
|
||||
* `ngx.re.match`
|
||||
* `ngx.re.find`
|
||||
* `ngx.re.gmatch`
|
||||
* `ngx.re.sub`
|
||||
* `ngx.re.gsub`
|
||||
|
||||
* `ngx.crc32_short`
|
||||
* `ngx.crc32_long`
|
||||
* `ngx.hmac_sha1`
|
||||
|
|
@ -9353,7 +9395,7 @@ The second argument `module_name` specifies the lua module name to execute in th
|
|||
|
||||
The third argument `func_name` specifies the function field in the module table as the second argument.
|
||||
|
||||
The type of `arg`s must be one of type below:
|
||||
The type of `args` must be one of type below:
|
||||
|
||||
* boolean
|
||||
* number
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ Production ready.
|
|||
= Version =
|
||||
|
||||
This document describes ngx_lua
|
||||
[https://github.com/openresty/lua-nginx-module/tags v0.10.19], which was released
|
||||
on 3 Nov, 2020.
|
||||
[https://github.com/openresty/lua-nginx-module/tags v0.10.25], which was released
|
||||
on 19 June 2023.
|
||||
|
||||
= Videos =
|
||||
|
||||
|
|
@ -2845,11 +2845,43 @@ The support for the <code>TLSv1.3</code> parameter requires version <code>v0.10.
|
|||
|
||||
This directive was first introduced in the <code>v0.9.11</code> release.
|
||||
|
||||
== lua_ssl_certificate ==
|
||||
|
||||
'''syntax:''' ''lua_ssl_certificate <file>''
|
||||
|
||||
'''default:''' ''none''
|
||||
|
||||
'''context:''' ''http, server, location''
|
||||
|
||||
Specifies the file path to the SSL/TLS certificate in PEM format used for the [[#tcpsock:sslhandshake|tcpsock:sslhandshake]] method.
|
||||
|
||||
This directive allows you to specify the SSL/TLS certificate that will be presented to server during the SSL/TLS handshake process.
|
||||
|
||||
This directive was first introduced in the <code>v0.10.26</code> release.
|
||||
|
||||
See also [[#lua_ssl_certificate_key|lua_ssl_certificate_key]] and [[#lua_ssl_verify_depth|lua_ssl_verify_depth]].
|
||||
|
||||
== lua_ssl_certificate_key ==
|
||||
|
||||
'''syntax:''' ''lua_ssl_certificate_key <file>''
|
||||
|
||||
'''default:''' ''none''
|
||||
|
||||
'''context:''' ''http, server, location''
|
||||
|
||||
Specifies the file path to the private key associated with the SSL/TLS certificate used in the [[#tcpsock:sslhandshake|tcpsock:sslhandshake]] method.
|
||||
|
||||
This directive allows you to specify the private key file corresponding to the SSL/TLS certificate specified by lua_ssl_certificate. The private key should be in PEM format and must match the certificate.
|
||||
|
||||
This directive was first introduced in the <code>v0.10.26</code> release.
|
||||
|
||||
See also [[#lua_ssl_certificate|lua_ssl_certificate]] and [[#lua_ssl_verify_depth|lua_ssl_verify_depth]].
|
||||
|
||||
== lua_ssl_trusted_certificate ==
|
||||
|
||||
'''syntax:''' ''lua_ssl_trusted_certificate <file>''
|
||||
|
||||
'''default:''' ''no''
|
||||
'''default:''' ''none''
|
||||
|
||||
'''context:''' ''http, server, location''
|
||||
|
||||
|
|
@ -2871,7 +2903,7 @@ Sets the verification depth in the server certificates chain.
|
|||
|
||||
This directive was first introduced in the <code>v0.9.11</code> release.
|
||||
|
||||
See also [[#lua_ssl_trusted_certificate|lua_ssl_trusted_certificate]].
|
||||
See also [[#lua_ssl_certificate|lua_ssl_certificate]], [[#lua_ssl_certificate_key|lua_ssl_certificate_key]] and [[#lua_ssl_trusted_certificate|lua_ssl_trusted_certificate]].
|
||||
|
||||
== lua_ssl_conf_command ==
|
||||
|
||||
|
|
@ -4555,12 +4587,14 @@ See also [[#ngx.req.read_body|ngx.req.read_body]].
|
|||
|
||||
== ngx.req.get_body_data ==
|
||||
|
||||
'''syntax:''' ''data = ngx.req.get_body_data()''
|
||||
'''syntax:''' ''data = ngx.req.get_body_data(max_bytes?)''
|
||||
|
||||
'''context:''' ''rewrite_by_lua*, access_by_lua*, content_by_lua*, log_by_lua*''
|
||||
|
||||
Retrieves in-memory request body data. It returns a Lua string rather than a Lua table holding all the parsed query arguments. Use the [[#ngx.req.get_post_args|ngx.req.get_post_args]] function instead if a Lua table is required.
|
||||
|
||||
The optional <code>max_bytes</code> function argument can be used when you don't need the entire body.
|
||||
|
||||
This function returns <code>nil</code> if
|
||||
|
||||
# the request body has not been read,
|
||||
|
|
@ -4707,6 +4741,8 @@ Returns a read-only cosocket object that wraps the downstream connection. Only [
|
|||
|
||||
In case of error, <code>nil</code> will be returned as well as a string describing the error.
|
||||
|
||||
Due to the streaming nature of HTTP2 and HTTP3, this API cannot be used when the downstream connection is HTTP2 and HTTP3.
|
||||
|
||||
The socket object returned by this method is usually used to read the current request's body in a streaming fashion. Do not turn on the [[#lua_need_request_body|lua_need_request_body]] directive, and do not mix this call with [[#ngx.req.read_body|ngx.req.read_body]] and [[#ngx.req.discard_body|ngx.req.discard_body]].
|
||||
|
||||
If any request body data has been pre-read into the Nginx core request header buffer, the resulting cosocket object will take care of this to avoid potential data loss resulting from such pre-reading.
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
/* Public API for other Nginx modules */
|
||||
|
||||
|
||||
#define ngx_http_lua_version 10025
|
||||
#define ngx_http_lua_version 10026
|
||||
|
||||
|
||||
typedef struct ngx_http_lua_co_ctx_s ngx_http_lua_co_ctx_t;
|
||||
|
|
|
|||
|
|
@ -137,6 +137,26 @@ ngx_http_lua_access_handler(ngx_http_request_t *r)
|
|||
}
|
||||
|
||||
if (llcf->force_read_body && !ctx->read_body_done) {
|
||||
|
||||
#if (NGX_HTTP_V2)
|
||||
if (r->main->stream && r->headers_in.content_length_n < 0) {
|
||||
ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
|
||||
"disable lua_need_request_body, since "
|
||||
"http2 read_body may break http2 stream process");
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
if (r->http_version == NGX_HTTP_VERSION_30
|
||||
&& r->headers_in.content_length_n < 0)
|
||||
{
|
||||
ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
|
||||
"disable lua_need_request_body, since "
|
||||
"http2 read_body may break http2 stream process");
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
r->request_body_in_single_buf = 1;
|
||||
r->request_body_in_persistent_file = 1;
|
||||
r->request_body_in_clean_file = 1;
|
||||
|
|
@ -154,6 +174,12 @@ ngx_http_lua_access_handler(ngx_http_request_t *r)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(NGX_HTTP_V3) || defined(NGX_HTTP_V2)
|
||||
|
||||
done:
|
||||
|
||||
#endif
|
||||
|
||||
dd("calling access handler");
|
||||
return llcf->access_handler(r);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@
|
|||
* | Int | At which line this function is defined
|
||||
* | [linedefined] |
|
||||
* ---------------------
|
||||
* | Int | At while line this function definition ended
|
||||
* | Int | At which line this function definition ended
|
||||
* | [lastlinedefined] |
|
||||
* ---------------------
|
||||
* | Char | Number of upvalues referenced by this function
|
||||
|
|
@ -128,7 +128,7 @@
|
|||
* | Vector | Debug lineinfo vector
|
||||
* | [lineinfo] | Empty vector here if debug info is stripped
|
||||
* ---------------------
|
||||
* | Int | Number of local variable in this function
|
||||
* | Int | Number of local variables in this function
|
||||
* | [sizelocvars] | 0 if debug info is stripped
|
||||
* ---------------------
|
||||
* | String | ------------------------------------
|
||||
|
|
|
|||
|
|
@ -55,11 +55,17 @@ typedef struct {
|
|||
|
||||
|
||||
#if (NGX_PCRE)
|
||||
#include <pcre.h>
|
||||
# if (PCRE_MAJOR > 8) || (PCRE_MAJOR == 8 && PCRE_MINOR >= 21)
|
||||
# if (NGX_PCRE2)
|
||||
# define LUA_HAVE_PCRE_JIT 1
|
||||
# else
|
||||
# define LUA_HAVE_PCRE_JIT 0
|
||||
|
||||
#include <pcre.h>
|
||||
|
||||
# if (PCRE_MAJOR > 8) || (PCRE_MAJOR == 8 && PCRE_MINOR >= 21)
|
||||
# define LUA_HAVE_PCRE_JIT 1
|
||||
# else
|
||||
# define LUA_HAVE_PCRE_JIT 0
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
@ -221,9 +227,14 @@ struct ngx_http_lua_main_conf_s {
|
|||
ngx_int_t regex_cache_entries;
|
||||
ngx_int_t regex_cache_max_entries;
|
||||
ngx_int_t regex_match_limit;
|
||||
# if (LUA_HAVE_PCRE_JIT)
|
||||
#endif
|
||||
|
||||
#if (LUA_HAVE_PCRE_JIT)
|
||||
#if (NGX_PCRE2)
|
||||
pcre2_jit_stack *jit_stack;
|
||||
#else
|
||||
pcre_jit_stack *jit_stack;
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
ngx_array_t *shm_zones; /* of ngx_shm_zone_t* */
|
||||
|
|
@ -360,6 +371,8 @@ union ngx_http_lua_srv_conf_u {
|
|||
typedef struct {
|
||||
#if (NGX_HTTP_SSL)
|
||||
ngx_ssl_t *ssl; /* shared by SSL cosockets */
|
||||
ngx_array_t *ssl_certificates;
|
||||
ngx_array_t *ssl_certificate_keys;
|
||||
ngx_uint_t ssl_protocols;
|
||||
ngx_str_t ssl_ciphers;
|
||||
ngx_uint_t ssl_verify_depth;
|
||||
|
|
|
|||
|
|
@ -196,6 +196,26 @@ ngx_http_lua_content_handler(ngx_http_request_t *r)
|
|||
}
|
||||
|
||||
if (llcf->force_read_body && !ctx->read_body_done) {
|
||||
|
||||
#if (NGX_HTTP_V2)
|
||||
if (r->main->stream && r->headers_in.content_length_n < 0) {
|
||||
ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
|
||||
"disable lua_need_request_body, since "
|
||||
"http2 read_body may break http2 stream process");
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
if (r->http_version == NGX_HTTP_VERSION_30
|
||||
&& r->headers_in.content_length_n < 0)
|
||||
{
|
||||
ngx_log_error(NGX_LOG_WARN, r->connection->log, 0,
|
||||
"disable lua_need_request_body, since "
|
||||
"http2 read_body may break http2 stream process");
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
r->request_body_in_single_buf = 1;
|
||||
r->request_body_in_persistent_file = 1;
|
||||
r->request_body_in_clean_file = 1;
|
||||
|
|
@ -214,6 +234,12 @@ ngx_http_lua_content_handler(ngx_http_request_t *r)
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(NGX_HTTP_V3) || defined(NGX_HTTP_V2)
|
||||
|
||||
done:
|
||||
|
||||
#endif
|
||||
|
||||
dd("setting entered");
|
||||
|
||||
ctx->entered_content_phase = 1;
|
||||
|
|
|
|||
|
|
@ -280,6 +280,9 @@ ngx_http_lua_ngx_redirect(lua_State *L)
|
|||
|
||||
h->value.len = len;
|
||||
h->value.data = uri;
|
||||
#if defined(nginx_version) && nginx_version >= 1023000
|
||||
h->next = NULL;
|
||||
#endif
|
||||
ngx_str_set(&h->key, "Location");
|
||||
|
||||
r->headers_out.status = rc;
|
||||
|
|
|
|||
|
|
@ -782,6 +782,11 @@ ngx_http_lua_ffi_req_get_headers_count(ngx_http_request_t *r, int max,
|
|||
{
|
||||
int count;
|
||||
ngx_list_part_t *part;
|
||||
#if (NGX_HTTP_V3)
|
||||
int has_host = 0;
|
||||
ngx_uint_t i;
|
||||
ngx_table_elt_t *header;
|
||||
#endif
|
||||
|
||||
if (r->connection->fd == (ngx_socket_t) -1) {
|
||||
return NGX_HTTP_LUA_FFI_BAD_CONTEXT;
|
||||
|
|
@ -794,11 +799,54 @@ ngx_http_lua_ffi_req_get_headers_count(ngx_http_request_t *r, int max,
|
|||
}
|
||||
|
||||
part = &r->headers_in.headers.part;
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
count = 0;
|
||||
header = part->elts;
|
||||
|
||||
if (r->http_version == NGX_HTTP_VERSION_30
|
||||
&& r->headers_in.server.data != NULL)
|
||||
{
|
||||
has_host = 1;
|
||||
count++;
|
||||
}
|
||||
|
||||
if (has_host == 1) {
|
||||
for (i = 0; /* void */; i++) {
|
||||
if (i >= part->nelts) {
|
||||
if (part->next == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
part = part->next;
|
||||
header = part->elts;
|
||||
i = 0;
|
||||
}
|
||||
|
||||
if (header[i].key.len == 4
|
||||
&& ngx_strncasecmp(header[i].key.data,
|
||||
(u_char *) "host", 4) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
} else {
|
||||
count = part->nelts;
|
||||
while (part->next != NULL) {
|
||||
part = part->next;
|
||||
count += part->nelts;
|
||||
}
|
||||
}
|
||||
#else
|
||||
count = part->nelts;
|
||||
while (part->next != NULL) {
|
||||
part = part->next;
|
||||
count += part->nelts;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (max > 0 && count > max) {
|
||||
*truncated = 1;
|
||||
|
|
@ -821,12 +869,29 @@ ngx_http_lua_ffi_req_get_headers(ngx_http_request_t *r,
|
|||
ngx_uint_t i;
|
||||
ngx_list_part_t *part;
|
||||
ngx_table_elt_t *header;
|
||||
#if (NGX_HTTP_V3)
|
||||
int has_host = 0;
|
||||
#endif
|
||||
|
||||
if (count <= 0) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
n = 0;
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
if (r->http_version == NGX_HTTP_VERSION_30
|
||||
&& r->headers_in.server.data != NULL)
|
||||
{
|
||||
out[n].key.data = (u_char *) "host";
|
||||
out[n].key.len = sizeof("host") - 1;
|
||||
out[n].value.len = r->headers_in.server.len;
|
||||
out[n].value.data = r->headers_in.server.data;
|
||||
has_host = 1;
|
||||
++n;
|
||||
}
|
||||
#endif
|
||||
|
||||
part = &r->headers_in.headers.part;
|
||||
header = part->elts;
|
||||
|
||||
|
|
@ -842,6 +907,14 @@ ngx_http_lua_ffi_req_get_headers(ngx_http_request_t *r,
|
|||
i = 0;
|
||||
}
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
if (has_host == 1 && header[i].key.len == 4
|
||||
&& ngx_strncasecmp(header[i].key.data, (u_char *) "host", 4) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (raw) {
|
||||
out[n].key.data = header[i].key.data;
|
||||
out[n].key.len = (int) header[i].key.len;
|
||||
|
|
|
|||
|
|
@ -280,6 +280,9 @@ new_header:
|
|||
|
||||
h->key = hv->key;
|
||||
h->value = *value;
|
||||
#if defined(nginx_version) && nginx_version >= 1023000
|
||||
h->next = NULL;
|
||||
#endif
|
||||
|
||||
h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);
|
||||
if (h->lowcase_key == NULL) {
|
||||
|
|
@ -588,19 +591,21 @@ ngx_http_set_builtin_multi_header(ngx_http_request_t *r,
|
|||
{
|
||||
#if defined(nginx_version) && nginx_version >= 1023000
|
||||
ngx_table_elt_t **headers, **ph, *h;
|
||||
int nelts;
|
||||
|
||||
headers = (ngx_table_elt_t **) ((char *) &r->headers_in + hv->offset);
|
||||
|
||||
if (!hv->no_override && *headers != NULL) {
|
||||
nelts = 0;
|
||||
#if defined(DDEBUG) && (DDEBUG)
|
||||
int nelts = 0;
|
||||
|
||||
for (h = *headers; h; h = h->next) {
|
||||
nelts++;
|
||||
}
|
||||
|
||||
*headers = NULL;
|
||||
|
||||
dd("clear multi-value headers: %d", nelts);
|
||||
#endif
|
||||
|
||||
*headers = NULL;
|
||||
}
|
||||
|
||||
if (ngx_http_set_header_helper(r, hv, value, &h) == NGX_ERROR) {
|
||||
|
|
|
|||
|
|
@ -229,6 +229,9 @@ new_header:
|
|||
|
||||
h->key = hv->key;
|
||||
h->value = *value;
|
||||
#if defined(nginx_version) && nginx_version >= 1023000
|
||||
h->next = NULL;
|
||||
#endif
|
||||
|
||||
h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);
|
||||
if (h->lowcase_key == NULL) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ static char *ngx_http_lua_merge_loc_conf(ngx_conf_t *cf, void *parent,
|
|||
static ngx_int_t ngx_http_lua_init(ngx_conf_t *cf);
|
||||
static char *ngx_http_lua_lowat_check(ngx_conf_t *cf, void *post, void *data);
|
||||
#if (NGX_HTTP_SSL)
|
||||
static ngx_int_t ngx_http_lua_merge_ssl(ngx_conf_t *cf,
|
||||
ngx_http_lua_loc_conf_t *conf, ngx_http_lua_loc_conf_t *prev);
|
||||
static ngx_int_t ngx_http_lua_set_ssl(ngx_conf_t *cf,
|
||||
ngx_http_lua_loc_conf_t *llcf);
|
||||
#if (nginx_version >= 1019004)
|
||||
|
|
@ -57,6 +59,9 @@ static char *ngx_http_lua_ssl_conf_command_check(ngx_conf_t *cf, void *post,
|
|||
#endif
|
||||
static char *ngx_http_lua_malloc_trim(ngx_conf_t *cf, ngx_command_t *cmd,
|
||||
void *conf);
|
||||
#if (NGX_PCRE2)
|
||||
extern void ngx_http_lua_regex_cleanup(void *data);
|
||||
#endif
|
||||
|
||||
|
||||
static ngx_conf_post_t ngx_http_lua_lowat_post =
|
||||
|
|
@ -648,6 +653,20 @@ static ngx_command_t ngx_http_lua_cmds[] = {
|
|||
offsetof(ngx_http_lua_loc_conf_t, ssl_verify_depth),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("lua_ssl_certificate"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_str_array_slot,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
offsetof(ngx_http_lua_loc_conf_t, ssl_certificates),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("lua_ssl_certificate_key"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_str_array_slot,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
offsetof(ngx_http_lua_loc_conf_t, ssl_certificate_keys),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("lua_ssl_trusted_certificate"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
||||
ngx_conf_set_str_slot,
|
||||
|
|
@ -839,6 +858,17 @@ ngx_http_lua_init(ngx_conf_t *cf)
|
|||
cln->data = lmcf;
|
||||
cln->handler = ngx_http_lua_sema_mm_cleanup;
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
/* add the cleanup of pcre2 regex */
|
||||
cln = ngx_pool_cleanup_add(cf->pool, 0);
|
||||
if (cln == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
cln->data = lmcf;
|
||||
cln->handler = ngx_http_lua_regex_cleanup;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NGX_LUA_PIPE
|
||||
ngx_http_lua_pipe_init();
|
||||
#endif
|
||||
|
|
@ -1148,15 +1178,15 @@ ngx_http_lua_create_srv_conf(ngx_conf_t *cf)
|
|||
* lscf->srv.ssl_cert_chunkname = NULL;
|
||||
* lscf->srv.ssl_cert_src_key = NULL;
|
||||
*
|
||||
* lscf->srv.ssl_session_store_handler = NULL;
|
||||
* lscf->srv.ssl_session_store_src = { 0, NULL };
|
||||
* lscf->srv.ssl_session_store_chunkname = NULL;
|
||||
* lscf->srv.ssl_session_store_src_key = NULL;
|
||||
* lscf->srv.ssl_sess_store_handler = NULL;
|
||||
* lscf->srv.ssl_sess_store_src = { 0, NULL };
|
||||
* lscf->srv.ssl_sess_store_chunkname = NULL;
|
||||
* lscf->srv.ssl_sess_store_src_key = NULL;
|
||||
*
|
||||
* lscf->srv.ssl_session_fetch_handler = NULL;
|
||||
* lscf->srv.ssl_session_fetch_src = { 0, NULL };
|
||||
* lscf->srv.ssl_session_fetch_chunkname = NULL;
|
||||
* lscf->srv.ssl_session_fetch_src_key = NULL;
|
||||
* lscf->srv.ssl_sess_fetch_handler = NULL;
|
||||
* lscf->srv.ssl_sess_fetch_src = { 0, NULL };
|
||||
* lscf->srv.ssl_sess_fetch_chunkname = NULL;
|
||||
* lscf->srv.ssl_sess_fetch_src_key = NULL;
|
||||
*
|
||||
* lscf->balancer.handler = NULL;
|
||||
* lscf->balancer.src = { 0, NULL };
|
||||
|
|
@ -1399,6 +1429,8 @@ ngx_http_lua_create_loc_conf(ngx_conf_t *cf)
|
|||
|
||||
#if (NGX_HTTP_SSL)
|
||||
conf->ssl_verify_depth = NGX_CONF_UNSET_UINT;
|
||||
conf->ssl_certificates = NGX_CONF_UNSET_PTR;
|
||||
conf->ssl_certificate_keys = NGX_CONF_UNSET_PTR;
|
||||
#if (nginx_version >= 1019004)
|
||||
conf->ssl_conf_commands = NGX_CONF_UNSET_PTR;
|
||||
#endif
|
||||
|
|
@ -1464,16 +1496,24 @@ ngx_http_lua_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
#if (NGX_HTTP_SSL)
|
||||
|
||||
if (ngx_http_lua_merge_ssl(cf, conf, prev) != NGX_OK) {
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
ngx_conf_merge_bitmask_value(conf->ssl_protocols, prev->ssl_protocols,
|
||||
(NGX_CONF_BITMASK_SET|NGX_SSL_SSLv3
|
||||
(NGX_CONF_BITMASK_SET
|
||||
|NGX_SSL_TLSv1|NGX_SSL_TLSv1_1
|
||||
|NGX_SSL_TLSv1_2));
|
||||
|NGX_SSL_TLSv1_2|NGX_SSL_TLSv1_3));
|
||||
|
||||
ngx_conf_merge_str_value(conf->ssl_ciphers, prev->ssl_ciphers,
|
||||
"DEFAULT");
|
||||
|
||||
ngx_conf_merge_uint_value(conf->ssl_verify_depth,
|
||||
prev->ssl_verify_depth, 1);
|
||||
ngx_conf_merge_ptr_value(conf->ssl_certificates,
|
||||
prev->ssl_certificates, NULL);
|
||||
ngx_conf_merge_ptr_value(conf->ssl_certificate_keys,
|
||||
prev->ssl_certificate_keys, NULL);
|
||||
ngx_conf_merge_str_value(conf->ssl_trusted_certificate,
|
||||
prev->ssl_trusted_certificate, "");
|
||||
ngx_conf_merge_str_value(conf->ssl_crl, prev->ssl_crl, "");
|
||||
|
|
@ -1527,17 +1567,77 @@ ngx_http_lua_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
#if (NGX_HTTP_SSL)
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_lua_merge_ssl(ngx_conf_t *cf,
|
||||
ngx_http_lua_loc_conf_t *conf, ngx_http_lua_loc_conf_t *prev)
|
||||
{
|
||||
ngx_uint_t preserve;
|
||||
|
||||
if (conf->ssl_protocols == 0
|
||||
&& conf->ssl_ciphers.data == NULL
|
||||
&& conf->ssl_verify_depth == NGX_CONF_UNSET_UINT
|
||||
&& conf->ssl_certificates == NGX_CONF_UNSET_PTR
|
||||
&& conf->ssl_certificate_keys == NGX_CONF_UNSET_PTR
|
||||
&& conf->ssl_trusted_certificate.data == NULL
|
||||
&& conf->ssl_crl.data == NULL
|
||||
#if (nginx_version >= 1019004)
|
||||
&& conf->ssl_conf_commands == NGX_CONF_UNSET_PTR
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if (prev->ssl) {
|
||||
conf->ssl = prev->ssl;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
preserve = 1;
|
||||
|
||||
} else {
|
||||
preserve = 0;
|
||||
}
|
||||
|
||||
conf->ssl = ngx_pcalloc(cf->pool, sizeof(ngx_ssl_t));
|
||||
if (conf->ssl == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
conf->ssl->log = cf->log;
|
||||
|
||||
/*
|
||||
* special handling to preserve conf->ssl_* in the "http" section
|
||||
* to inherit it to all servers
|
||||
*/
|
||||
|
||||
if (preserve) {
|
||||
prev->ssl = conf->ssl;
|
||||
}
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_lua_set_ssl(ngx_conf_t *cf, ngx_http_lua_loc_conf_t *llcf)
|
||||
{
|
||||
ngx_pool_cleanup_t *cln;
|
||||
|
||||
llcf->ssl = ngx_pcalloc(cf->pool, sizeof(ngx_ssl_t));
|
||||
if (llcf->ssl == NULL) {
|
||||
return NGX_ERROR;
|
||||
if (llcf->ssl->ctx) {
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
llcf->ssl->log = cf->log;
|
||||
if (llcf->ssl_certificates) {
|
||||
if (llcf->ssl_certificate_keys == NULL
|
||||
|| llcf->ssl_certificate_keys->nelts
|
||||
< llcf->ssl_certificates->nelts)
|
||||
{
|
||||
ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
|
||||
"no \"lua_ssl_certificate_key\" is defined "
|
||||
"for certificate \"%V\"",
|
||||
((ngx_str_t *) llcf->ssl_certificates->elts)
|
||||
+ llcf->ssl_certificates->nelts - 1);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (ngx_ssl_create(llcf->ssl, llcf->ssl_protocols, NULL) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
|
|
@ -1562,6 +1662,16 @@ ngx_http_lua_set_ssl(ngx_conf_t *cf, ngx_http_lua_loc_conf_t *llcf)
|
|||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (llcf->ssl_certificates
|
||||
&& ngx_ssl_certificates(cf, llcf->ssl,
|
||||
llcf->ssl_certificates,
|
||||
llcf->ssl_certificate_keys,
|
||||
NULL)
|
||||
!= NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (llcf->ssl_trusted_certificate.len
|
||||
&& ngx_ssl_trusted_certificate(cf, llcf->ssl,
|
||||
&llcf->ssl_trusted_certificate,
|
||||
|
|
|
|||
|
|
@ -18,15 +18,61 @@
|
|||
|
||||
static ngx_pool_t *ngx_http_lua_pcre_pool = NULL;
|
||||
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
static ngx_uint_t ngx_regex_direct_alloc;
|
||||
#else
|
||||
static void *(*old_pcre_malloc)(size_t);
|
||||
static void (*old_pcre_free)(void *ptr);
|
||||
#endif
|
||||
|
||||
|
||||
/* XXX: work-around to nginx regex subsystem, must init a memory pool
|
||||
* to use PCRE functions. As PCRE still has memory-leaking problems,
|
||||
* and nginx overwrote pcre_malloc/free hooks with its own static
|
||||
* functions, so nobody else can reuse nginx regex subsystem... */
|
||||
static void *
|
||||
#if (NGX_PCRE2)
|
||||
|
||||
void *
|
||||
ngx_http_lua_pcre_malloc(size_t size, void *data)
|
||||
{
|
||||
dd("lua pcre pool is %p", ngx_http_lua_pcre_pool);
|
||||
|
||||
if (ngx_http_lua_pcre_pool) {
|
||||
return ngx_palloc(ngx_http_lua_pcre_pool, size);
|
||||
}
|
||||
|
||||
if (ngx_regex_direct_alloc) {
|
||||
return ngx_alloc(size, ngx_cycle->log);
|
||||
}
|
||||
|
||||
fprintf(stderr, "error: lua pcre malloc failed due to empty pcre pool");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ngx_http_lua_pcre_free(void *ptr, void *data)
|
||||
{
|
||||
dd("lua pcre pool is %p", ngx_http_lua_pcre_pool);
|
||||
|
||||
if (ngx_http_lua_pcre_pool) {
|
||||
ngx_pfree(ngx_http_lua_pcre_pool, ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ngx_regex_direct_alloc) {
|
||||
ngx_free(ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "error: lua pcre free failed due to empty pcre pool");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void *
|
||||
ngx_http_lua_pcre_malloc(size_t size)
|
||||
{
|
||||
dd("lua pcre pool is %p", ngx_http_lua_pcre_pool);
|
||||
|
|
@ -54,6 +100,41 @@ ngx_http_lua_pcre_free(void *ptr)
|
|||
fprintf(stderr, "error: lua pcre free failed due to empty pcre pool");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
|
||||
ngx_pool_t *
|
||||
ngx_http_lua_pcre_malloc_init(ngx_pool_t *pool)
|
||||
{
|
||||
ngx_pool_t *old_pool;
|
||||
|
||||
dd("lua pcre pool was %p", ngx_http_lua_pcre_pool);
|
||||
|
||||
ngx_regex_direct_alloc = (pool == NULL) ? 1 : 0;
|
||||
|
||||
old_pool = ngx_http_lua_pcre_pool;
|
||||
ngx_http_lua_pcre_pool = pool;
|
||||
|
||||
dd("lua pcre pool is %p", ngx_http_lua_pcre_pool);
|
||||
|
||||
return old_pool;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ngx_http_lua_pcre_malloc_done(ngx_pool_t *old_pool)
|
||||
{
|
||||
dd("lua pcre pool was %p", ngx_http_lua_pcre_pool);
|
||||
|
||||
ngx_http_lua_pcre_pool = old_pool;
|
||||
ngx_regex_direct_alloc = 0;
|
||||
|
||||
dd("lua pcre pool is %p", ngx_http_lua_pcre_pool);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
ngx_pool_t *
|
||||
ngx_http_lua_pcre_malloc_init(ngx_pool_t *pool)
|
||||
|
|
@ -101,6 +182,7 @@ ngx_http_lua_pcre_malloc_done(ngx_pool_t *old_pool)
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* NGX_PCRE */
|
||||
|
||||
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */
|
||||
|
|
|
|||
|
|
@ -13,8 +13,15 @@
|
|||
|
||||
|
||||
#if (NGX_PCRE)
|
||||
|
||||
ngx_pool_t *ngx_http_lua_pcre_malloc_init(ngx_pool_t *pool);
|
||||
void ngx_http_lua_pcre_malloc_done(ngx_pool_t *old_pool);
|
||||
|
||||
#if NGX_PCRE2
|
||||
void *ngx_http_lua_pcre_malloc(size_t size, void *data);
|
||||
void ngx_http_lua_pcre_free(void *ptr, void *data);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#endif
|
||||
#include "ddebug.h"
|
||||
|
||||
|
||||
#if (NGX_PCRE)
|
||||
|
||||
#include "ngx_http_lua_pcrefix.h"
|
||||
|
|
@ -17,13 +16,24 @@
|
|||
#include "ngx_http_lua_util.h"
|
||||
|
||||
|
||||
#if (PCRE_MAJOR >= 6)
|
||||
#if (PCRE_MAJOR >= 6 || NGX_PCRE2)
|
||||
# define LUA_HAVE_PCRE_DFA 1
|
||||
#else
|
||||
# define LUA_HAVE_PCRE_DFA 0
|
||||
#endif
|
||||
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
static pcre2_compile_context *ngx_regex_compile_context;
|
||||
static pcre2_match_context *ngx_regex_match_context;
|
||||
static pcre2_match_data *ngx_regex_match_data;
|
||||
static ngx_uint_t ngx_regex_match_data_size = 0;
|
||||
|
||||
#define PCRE2_VERSION_SIZE 64
|
||||
static char ngx_pcre2_version[PCRE2_VERSION_SIZE];
|
||||
#endif
|
||||
|
||||
|
||||
#define NGX_LUA_RE_MODE_DFA (1<<1)
|
||||
#define NGX_LUA_RE_MODE_JIT (1<<2)
|
||||
#define NGX_LUA_RE_NO_UTF8_CHECK (1<<4)
|
||||
|
|
@ -42,8 +52,17 @@ typedef struct {
|
|||
int ncaptures;
|
||||
int *captures;
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
pcre2_code *regex;
|
||||
/*
|
||||
* pcre2 doesn't use pcre_extra any more,
|
||||
* just for keeping same memory layout in the lua ffi cdef
|
||||
*/
|
||||
void *regex_sd;
|
||||
#else
|
||||
pcre *regex;
|
||||
pcre_extra *regex_sd;
|
||||
#endif
|
||||
|
||||
ngx_http_lua_complex_value_t *replace;
|
||||
|
||||
|
|
@ -57,7 +76,11 @@ typedef struct {
|
|||
ngx_pool_t *pool;
|
||||
ngx_int_t options;
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
pcre2_code *regex;
|
||||
#else
|
||||
pcre *regex;
|
||||
#endif
|
||||
int captures;
|
||||
ngx_str_t err;
|
||||
} ngx_http_lua_regex_compile_t;
|
||||
|
|
@ -65,8 +88,12 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
ngx_http_request_t *request;
|
||||
#if (NGX_PCRE2)
|
||||
pcre2_code *regex;
|
||||
#else
|
||||
pcre *regex;
|
||||
pcre_extra *regex_sd;
|
||||
#endif
|
||||
int ncaptures;
|
||||
int *captures;
|
||||
int captures_len;
|
||||
|
|
@ -74,8 +101,6 @@ typedef struct {
|
|||
} ngx_http_lua_regex_ctx_t;
|
||||
|
||||
|
||||
static void ngx_http_lua_regex_free_study_data(ngx_pool_t *pool,
|
||||
pcre_extra *sd);
|
||||
static ngx_int_t ngx_http_lua_regex_compile(ngx_http_lua_regex_compile_t *rc);
|
||||
|
||||
|
||||
|
|
@ -91,22 +116,156 @@ static ngx_int_t ngx_http_lua_regex_compile(ngx_http_lua_regex_compile_t *rc);
|
|||
|
||||
|
||||
static void
|
||||
ngx_http_lua_regex_free_study_data(ngx_pool_t *pool, pcre_extra *sd)
|
||||
ngx_http_lua_regex_free_study_data(ngx_pool_t *pool, ngx_http_lua_regex_t *re)
|
||||
{
|
||||
ngx_pool_t *old_pool;
|
||||
ngx_pool_t *old_pool;
|
||||
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
#if (NGX_PCRE2)
|
||||
if (re && re->regex) {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
|
||||
#if LUA_HAVE_PCRE_JIT
|
||||
pcre_free_study(sd);
|
||||
pcre2_code_free(re->regex);
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
re->regex = NULL;
|
||||
}
|
||||
#else
|
||||
pcre_free(sd);
|
||||
if (re && re->regex_sd) {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
#if LUA_HAVE_PCRE_JIT
|
||||
pcre_free_study(re->regex_sd);
|
||||
#else
|
||||
pcre_free(re->regex_sd);
|
||||
#endif
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
re->regex_sd = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
static ngx_int_t
|
||||
ngx_http_lua_regex_compile(ngx_http_lua_regex_compile_t *rc)
|
||||
{
|
||||
int n, errcode;
|
||||
char *p;
|
||||
size_t erroff;
|
||||
u_char errstr[128];
|
||||
pcre2_code *re;
|
||||
ngx_pool_t *old_pool;
|
||||
pcre2_general_context *gctx;
|
||||
pcre2_compile_context *cctx;
|
||||
|
||||
ngx_http_lua_main_conf_t *lmcf;
|
||||
|
||||
if (ngx_regex_compile_context == NULL) {
|
||||
/*
|
||||
* Allocate a compile context if not yet allocated. This uses
|
||||
* direct allocations from heap, so the result can be cached
|
||||
* even at runtime.
|
||||
*/
|
||||
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(NULL);
|
||||
|
||||
gctx = pcre2_general_context_create(ngx_http_lua_pcre_malloc,
|
||||
ngx_http_lua_pcre_free,
|
||||
NULL);
|
||||
if (gctx == NULL) {
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
cctx = pcre2_compile_context_create(gctx);
|
||||
if (cctx == NULL) {
|
||||
pcre2_general_context_free(gctx);
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
ngx_regex_compile_context = cctx;
|
||||
|
||||
ngx_regex_match_context = pcre2_match_context_create(gctx);
|
||||
if (ngx_regex_match_context == NULL) {
|
||||
pcre2_general_context_free(gctx);
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
lmcf = ngx_http_cycle_get_module_main_conf(ngx_cycle,
|
||||
ngx_http_lua_module);
|
||||
if (lmcf && lmcf->regex_match_limit > 0) {
|
||||
pcre2_set_match_limit(ngx_regex_match_context,
|
||||
lmcf->regex_match_limit);
|
||||
}
|
||||
|
||||
pcre2_general_context_free(gctx);
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
}
|
||||
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(rc->pool);
|
||||
|
||||
re = pcre2_compile(rc->pattern.data,
|
||||
rc->pattern.len, rc->options,
|
||||
&errcode, &erroff, ngx_regex_compile_context);
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
if (re == NULL) {
|
||||
pcre2_get_error_message(errcode, errstr, 128);
|
||||
|
||||
if ((size_t) erroff == rc->pattern.len) {
|
||||
rc->err.len = ngx_snprintf(rc->err.data, rc->err.len,
|
||||
"pcre2_compile() failed: %s in \"%V\"",
|
||||
errstr, &rc->pattern)
|
||||
- rc->err.data;
|
||||
|
||||
} else {
|
||||
rc->err.len = ngx_snprintf(rc->err.data, rc->err.len,
|
||||
"pcre2_compile() failed: %s in "
|
||||
"\"%V\" at \"%s\"", errstr, &rc->pattern,
|
||||
rc->pattern.data + erroff)
|
||||
- rc->err.data;
|
||||
}
|
||||
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
rc->regex = re;
|
||||
|
||||
n = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &rc->captures);
|
||||
if (n < 0) {
|
||||
p = "pcre2_pattern_info(\"%V\", PCRE_INFO_CAPTURECOUNT) failed: %d";
|
||||
goto failed;
|
||||
}
|
||||
|
||||
#if (NGX_DEBUG)
|
||||
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
||||
"pcre2_compile: pattern[%V], options 0x%08Xd, ncaptures %d",
|
||||
&rc->pattern, rc->options, rc->captures);
|
||||
#endif
|
||||
|
||||
return NGX_OK;
|
||||
|
||||
failed:
|
||||
|
||||
rc->err.len = ngx_snprintf(rc->err.data, rc->err.len, p, &rc->pattern, n)
|
||||
- rc->err.data;
|
||||
return NGX_ERROR;
|
||||
|
||||
nomem:
|
||||
|
||||
rc->err.len = ngx_snprintf(rc->err.data, rc->err.len,
|
||||
"regex \"%V\" compilation failed: no memory",
|
||||
&rc->pattern)
|
||||
- rc->err.data;
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_lua_regex_compile(ngx_http_lua_regex_compile_t *rc)
|
||||
{
|
||||
|
|
@ -159,13 +318,14 @@ failed:
|
|||
- rc->err.data;
|
||||
return NGX_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_lua_ffi_set_jit_stack_size(int size, u_char *errstr,
|
||||
size_t *errstr_size)
|
||||
{
|
||||
#if LUA_HAVE_PCRE_JIT
|
||||
#if (LUA_HAVE_PCRE_JIT)
|
||||
|
||||
ngx_http_lua_main_conf_t *lmcf;
|
||||
ngx_pool_t *pool, *old_pool;
|
||||
|
|
@ -186,15 +346,24 @@ ngx_http_lua_ffi_set_jit_stack_size(int size, u_char *errstr,
|
|||
if (lmcf->jit_stack) {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
pcre2_jit_stack_free(lmcf->jit_stack);
|
||||
#else
|
||||
pcre_jit_stack_free(lmcf->jit_stack);
|
||||
#endif
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
}
|
||||
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
lmcf->jit_stack = pcre2_jit_stack_create(NGX_LUA_RE_MIN_JIT_STACK_SIZE,
|
||||
size, NULL);
|
||||
#else
|
||||
lmcf->jit_stack = pcre_jit_stack_alloc(NGX_LUA_RE_MIN_JIT_STACK_SIZE,
|
||||
size);
|
||||
#endif
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
|
|
@ -214,10 +383,150 @@ ngx_http_lua_ffi_set_jit_stack_size(int size, u_char *errstr,
|
|||
- errstr;
|
||||
return NGX_ERROR;
|
||||
|
||||
#endif /* LUA_HAVE_PCRE_JIT */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
static void
|
||||
ngx_http_lua_regex_jit_compile(ngx_http_lua_regex_t *re, int flags,
|
||||
ngx_pool_t *pool, ngx_http_lua_main_conf_t *lmcf,
|
||||
ngx_http_lua_regex_compile_t *re_comp)
|
||||
{
|
||||
ngx_int_t ret;
|
||||
ngx_pool_t *old_pool;
|
||||
|
||||
if (flags & NGX_LUA_RE_MODE_JIT) {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
ret = pcre2_jit_compile(re_comp->regex, PCRE2_JIT_COMPLETE);
|
||||
|
||||
if (ret != 0) {
|
||||
ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, 0,
|
||||
"pcre2_jit_compile() failed: %d in \"%V\", "
|
||||
"ignored",
|
||||
ret, &re_comp->pattern);
|
||||
|
||||
#if (NGX_DEBUG)
|
||||
|
||||
} else {
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
||||
"pcre2 JIT compiled successfully");
|
||||
# endif /* !(NGX_DEBUG) */
|
||||
}
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
}
|
||||
|
||||
if (lmcf && lmcf->jit_stack) {
|
||||
pcre2_jit_stack_assign(ngx_regex_match_context, NULL,
|
||||
lmcf->jit_stack);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void
|
||||
ngx_http_lua_regex_jit_compile(ngx_http_lua_regex_t *re, int flags,
|
||||
ngx_pool_t *pool, ngx_http_lua_main_conf_t *lmcf,
|
||||
ngx_http_lua_regex_compile_t *re_comp)
|
||||
{
|
||||
const char *msg;
|
||||
pcre_extra *sd = NULL;
|
||||
ngx_pool_t *old_pool;
|
||||
|
||||
|
||||
#if (LUA_HAVE_PCRE_JIT)
|
||||
if (flags & NGX_LUA_RE_MODE_JIT) {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
sd = pcre_study(re_comp->regex, PCRE_STUDY_JIT_COMPILE, &msg);
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
# if (NGX_DEBUG)
|
||||
if (msg != NULL) {
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
||||
"pcre study failed with PCRE_STUDY_JIT_COMPILE: "
|
||||
"%s (%p)", msg, sd);
|
||||
}
|
||||
|
||||
if (sd != NULL) {
|
||||
int jitted;
|
||||
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
|
||||
pcre_fullinfo(re_comp->regex, sd, PCRE_INFO_JIT, &jitted);
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
||||
"pcre JIT compiling result: %d", jitted);
|
||||
}
|
||||
# endif /* !(NGX_DEBUG) */
|
||||
|
||||
} else {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
sd = pcre_study(re_comp->regex, 0, &msg);
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
}
|
||||
|
||||
if (sd && lmcf && lmcf->jit_stack) {
|
||||
pcre_assign_jit_stack(sd, NULL, lmcf->jit_stack);
|
||||
}
|
||||
|
||||
if (sd
|
||||
&& lmcf && lmcf->regex_match_limit > 0
|
||||
&& !(flags & NGX_LUA_RE_MODE_DFA))
|
||||
{
|
||||
sd->flags |= PCRE_EXTRA_MATCH_LIMIT;
|
||||
sd->match_limit = lmcf->regex_match_limit;
|
||||
}
|
||||
|
||||
#endif /* LUA_HAVE_PCRE_JIT */
|
||||
|
||||
re->regex_sd = sd;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
void
|
||||
ngx_http_lua_regex_cleanup(void *data)
|
||||
{
|
||||
ngx_pool_t *old_pool;
|
||||
ngx_http_lua_main_conf_t *lmcf;
|
||||
|
||||
lmcf = data;
|
||||
|
||||
if (ngx_regex_compile_context) {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(NULL);
|
||||
pcre2_compile_context_free(ngx_regex_compile_context);
|
||||
ngx_regex_compile_context = NULL;
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
}
|
||||
|
||||
if (lmcf && lmcf->jit_stack) {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(NULL);
|
||||
|
||||
pcre2_jit_stack_free(lmcf->jit_stack);
|
||||
lmcf->jit_stack = NULL;
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
}
|
||||
|
||||
if (ngx_regex_match_data) {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(NULL);
|
||||
pcre2_match_data_free(ngx_regex_match_data);
|
||||
ngx_regex_match_data = NULL;
|
||||
ngx_regex_match_data_size = 0;
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ngx_http_lua_regex_t *
|
||||
ngx_http_lua_ffi_compile_regex(const unsigned char *pat, size_t pat_len,
|
||||
int flags, int pcre_opts, u_char *errstr,
|
||||
|
|
@ -228,8 +537,7 @@ ngx_http_lua_ffi_compile_regex(const unsigned char *pat, size_t pat_len,
|
|||
ngx_int_t rc;
|
||||
const char *msg;
|
||||
ngx_pool_t *pool, *old_pool;
|
||||
pcre_extra *sd = NULL;
|
||||
ngx_http_lua_regex_t *re;
|
||||
ngx_http_lua_regex_t *re = NULL;
|
||||
|
||||
ngx_http_lua_main_conf_t *lmcf;
|
||||
ngx_http_lua_regex_compile_t re_comp;
|
||||
|
|
@ -251,6 +559,8 @@ ngx_http_lua_ffi_compile_regex(const unsigned char *pat, size_t pat_len,
|
|||
}
|
||||
|
||||
re->pool = pool;
|
||||
re->regex = NULL;
|
||||
re->regex_sd = NULL;
|
||||
|
||||
re_comp.options = pcre_opts;
|
||||
re_comp.pattern.data = (u_char *) pat;
|
||||
|
|
@ -274,54 +584,7 @@ ngx_http_lua_ffi_compile_regex(const unsigned char *pat, size_t pat_len,
|
|||
|
||||
ngx_http_lua_assert(lmcf != NULL);
|
||||
|
||||
#if (LUA_HAVE_PCRE_JIT)
|
||||
|
||||
if (flags & NGX_LUA_RE_MODE_JIT) {
|
||||
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
sd = pcre_study(re_comp.regex, PCRE_STUDY_JIT_COMPILE, &msg);
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
# if (NGX_DEBUG)
|
||||
if (msg != NULL) {
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
||||
"pcre study failed with PCRE_STUDY_JIT_COMPILE: "
|
||||
"%s (%p)", msg, sd);
|
||||
}
|
||||
|
||||
if (sd != NULL) {
|
||||
int jitted;
|
||||
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
|
||||
pcre_fullinfo(re_comp.regex, sd, PCRE_INFO_JIT, &jitted);
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
||||
"pcre JIT compiling result: %d", jitted);
|
||||
}
|
||||
# endif /* !(NGX_DEBUG) */
|
||||
|
||||
} else {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(pool);
|
||||
sd = pcre_study(re_comp.regex, 0, &msg);
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
}
|
||||
|
||||
if (sd && lmcf->jit_stack) {
|
||||
pcre_assign_jit_stack(sd, NULL, lmcf->jit_stack);
|
||||
}
|
||||
|
||||
#endif /* LUA_HAVE_PCRE_JIT */
|
||||
|
||||
if (sd
|
||||
&& lmcf && lmcf->regex_match_limit > 0
|
||||
&& !(flags & NGX_LUA_RE_MODE_DFA))
|
||||
{
|
||||
sd->flags |= PCRE_EXTRA_MATCH_LIMIT;
|
||||
sd->match_limit = lmcf->regex_match_limit;
|
||||
}
|
||||
ngx_http_lua_regex_jit_compile(re, flags, pool, lmcf, &re_comp);
|
||||
|
||||
if (flags & NGX_LUA_RE_MODE_DFA) {
|
||||
ovecsize = 2;
|
||||
|
|
@ -339,6 +602,31 @@ ngx_http_lua_ffi_compile_regex(const unsigned char *pat, size_t pat_len,
|
|||
goto error;
|
||||
}
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
if (pcre2_pattern_info(re_comp.regex, PCRE2_INFO_NAMECOUNT,
|
||||
&re->name_count) < 0)
|
||||
{
|
||||
msg = "cannot acquire named subpattern count";
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (re->name_count > 0) {
|
||||
if (pcre2_pattern_info(re_comp.regex, PCRE2_INFO_NAMEENTRYSIZE,
|
||||
&re->name_entry_size) != 0)
|
||||
{
|
||||
msg = "cannot acquire named subpattern entry size";
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (pcre2_pattern_info(re_comp.regex, PCRE2_INFO_NAMETABLE,
|
||||
&re->name_table) != 0)
|
||||
{
|
||||
msg = "cannot acquire named subpattern table";
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
if (pcre_fullinfo(re_comp.regex, NULL, PCRE_INFO_NAMECOUNT,
|
||||
&re->name_count) != 0)
|
||||
{
|
||||
|
|
@ -361,9 +649,9 @@ ngx_http_lua_ffi_compile_regex(const unsigned char *pat, size_t pat_len,
|
|||
goto error;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
re->regex = re_comp.regex;
|
||||
re->regex_sd = sd;
|
||||
re->ncaptures = re_comp.captures;
|
||||
re->captures = cap;
|
||||
re->replace = NULL;
|
||||
|
|
@ -379,9 +667,7 @@ error:
|
|||
p = ngx_snprintf(errstr, errstr_size - 1, "%s", msg);
|
||||
*p = '\0';
|
||||
|
||||
if (sd) {
|
||||
ngx_http_lua_regex_free_study_data(pool, sd);
|
||||
}
|
||||
ngx_http_lua_regex_free_study_data(pool, re);
|
||||
|
||||
if (pool) {
|
||||
ngx_destroy_pool(pool);
|
||||
|
|
@ -391,6 +677,103 @@ error:
|
|||
}
|
||||
|
||||
|
||||
#if (NGX_PCRE2)
|
||||
int
|
||||
ngx_http_lua_ffi_exec_regex(ngx_http_lua_regex_t *re, int flags,
|
||||
const u_char *s, size_t len, int pos)
|
||||
{
|
||||
int rc, exec_opts = 0;
|
||||
size_t *ov;
|
||||
ngx_uint_t ovecsize, n, i;
|
||||
ngx_pool_t *old_pool;
|
||||
|
||||
if (flags & NGX_LUA_RE_MODE_DFA) {
|
||||
ovecsize = 2;
|
||||
re->ncaptures = 0;
|
||||
|
||||
} else {
|
||||
ovecsize = (re->ncaptures + 1) * 3;
|
||||
}
|
||||
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(NULL);
|
||||
|
||||
if (ngx_regex_match_data == NULL
|
||||
|| ovecsize > ngx_regex_match_data_size)
|
||||
{
|
||||
/*
|
||||
* Allocate a match data if not yet allocated or smaller than
|
||||
* needed.
|
||||
*/
|
||||
|
||||
if (ngx_regex_match_data) {
|
||||
pcre2_match_data_free(ngx_regex_match_data);
|
||||
}
|
||||
|
||||
ngx_regex_match_data_size = ovecsize;
|
||||
ngx_regex_match_data = pcre2_match_data_create(ovecsize / 3, NULL);
|
||||
|
||||
if (ngx_regex_match_data == NULL) {
|
||||
rc = PCRE2_ERROR_NOMEMORY;
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & NGX_LUA_RE_NO_UTF8_CHECK) {
|
||||
exec_opts = PCRE2_NO_UTF_CHECK;
|
||||
|
||||
} else {
|
||||
exec_opts = 0;
|
||||
}
|
||||
|
||||
if (flags & NGX_LUA_RE_MODE_DFA) {
|
||||
int ws[NGX_LUA_RE_DFA_MODE_WORKSPACE_COUNT];
|
||||
rc = pcre2_dfa_match(re->regex, s, len, pos, exec_opts,
|
||||
ngx_regex_match_data, ngx_regex_match_context,
|
||||
ws, sizeof(ws) / sizeof(ws[0]));
|
||||
|
||||
|
||||
} else {
|
||||
rc = pcre2_match(re->regex, s, len, pos, exec_opts,
|
||||
ngx_regex_match_data, ngx_regex_match_context);
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
#if (NGX_DEBUG)
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
||||
"pcre2_match failed: flags 0x%05Xd, options 0x%08Xd, "
|
||||
"rc %d, ovecsize %ui", flags, exec_opts, rc, ovecsize);
|
||||
#endif
|
||||
|
||||
goto failed;
|
||||
}
|
||||
|
||||
n = pcre2_get_ovector_count(ngx_regex_match_data);
|
||||
ov = pcre2_get_ovector_pointer(ngx_regex_match_data);
|
||||
|
||||
#if (NGX_DEBUG)
|
||||
ngx_log_debug5(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
|
||||
"pcre2_match: flags 0x%05Xd, options 0x%08Xd, rc %d, "
|
||||
"n %ui, ovecsize %ui", flags, exec_opts, rc, n, ovecsize);
|
||||
#endif
|
||||
|
||||
if (!(flags & NGX_LUA_RE_MODE_DFA) && n > ovecsize / 3) {
|
||||
n = ovecsize / 3;
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
re->captures[i * 2] = ov[i * 2];
|
||||
re->captures[i * 2 + 1] = ov[i * 2 + 1];
|
||||
}
|
||||
|
||||
failed:
|
||||
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int
|
||||
ngx_http_lua_ffi_exec_regex(ngx_http_lua_regex_t *re, int flags,
|
||||
const u_char *s, size_t len, int pos)
|
||||
|
|
@ -427,7 +810,8 @@ ngx_http_lua_ffi_exec_regex(ngx_http_lua_regex_t *re, int flags,
|
|||
int ws[NGX_LUA_RE_DFA_MODE_WORKSPACE_COUNT];
|
||||
rc = ngx_http_lua_regex_dfa_exec(re->regex, sd, &subj,
|
||||
(int) pos, cap, ovecsize, ws,
|
||||
sizeof(ws)/sizeof(ws[0]), exec_opts);
|
||||
sizeof(ws) / sizeof(ws[0]),
|
||||
exec_opts);
|
||||
|
||||
#else
|
||||
|
||||
|
|
@ -443,28 +827,19 @@ ngx_http_lua_ffi_exec_regex(ngx_http_lua_regex_t *re, int flags,
|
|||
return rc;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
ngx_http_lua_ffi_destroy_regex(ngx_http_lua_regex_t *re)
|
||||
{
|
||||
ngx_pool_t *old_pool;
|
||||
|
||||
dd("destroy regex called");
|
||||
|
||||
if (re == NULL || re->pool == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (re->regex_sd) {
|
||||
old_pool = ngx_http_lua_pcre_malloc_init(re->pool);
|
||||
#if LUA_HAVE_PCRE_JIT
|
||||
pcre_free_study(re->regex_sd);
|
||||
#else
|
||||
pcre_free(re->regex_sd);
|
||||
#endif
|
||||
ngx_http_lua_pcre_malloc_done(old_pool);
|
||||
re->regex_sd = NULL;
|
||||
}
|
||||
ngx_http_lua_regex_free_study_data(re->pool, re);
|
||||
|
||||
ngx_destroy_pool(re->pool);
|
||||
}
|
||||
|
|
@ -592,7 +967,13 @@ ngx_http_lua_ffi_max_regex_cache_size(void)
|
|||
const char *
|
||||
ngx_http_lua_ffi_pcre_version(void)
|
||||
{
|
||||
#if (NGX_PCRE2)
|
||||
pcre2_config(PCRE2_CONFIG_VERSION, ngx_pcre2_version);
|
||||
|
||||
return ngx_pcre2_version;
|
||||
#else
|
||||
return pcre_version();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,23 @@ ngx_http_lua_ngx_req_read_body(lua_State *L)
|
|||
return luaL_error(L, "request object not found");
|
||||
}
|
||||
|
||||
/* http2 read body may break http2 stream process */
|
||||
#if (NGX_HTTP_V2)
|
||||
if (r->main->stream && r->headers_in.content_length_n < 0) {
|
||||
return luaL_error(L, "http2 requests are not supported"
|
||||
" without content-length header");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
if (r->http_version == NGX_HTTP_VERSION_30
|
||||
&& r->headers_in.content_length_n < 0)
|
||||
{
|
||||
return luaL_error(L, "http3 requests are not supported"
|
||||
" without content-length header");
|
||||
}
|
||||
#endif
|
||||
|
||||
r->request_body_in_single_buf = 1;
|
||||
r->request_body_in_persistent_file = 1;
|
||||
r->request_body_in_clean_file = 1;
|
||||
|
|
@ -229,15 +246,21 @@ ngx_http_lua_ngx_req_get_body_data(lua_State *L)
|
|||
{
|
||||
ngx_http_request_t *r;
|
||||
int n;
|
||||
size_t len;
|
||||
size_t len, max;
|
||||
size_t size, rest;
|
||||
ngx_chain_t *cl;
|
||||
u_char *p;
|
||||
u_char *buf;
|
||||
|
||||
n = lua_gettop(L);
|
||||
|
||||
if (n != 0) {
|
||||
return luaL_error(L, "expecting 0 arguments but seen %d", n);
|
||||
if (n != 0 && n != 1) {
|
||||
return luaL_error(L, "expecting 0 or 1 arguments but seen %d", n);
|
||||
}
|
||||
|
||||
max = 0;
|
||||
if (n == 1) {
|
||||
max = (size_t) luaL_checknumber(L, 1);
|
||||
}
|
||||
|
||||
r = ngx_http_lua_get_req(L);
|
||||
|
|
@ -265,6 +288,7 @@ ngx_http_lua_ngx_req_get_body_data(lua_State *L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
len = (max > 0 && len > max) ? max : len;
|
||||
lua_pushlstring(L, (char *) cl->buf->pos, len);
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -275,7 +299,13 @@ ngx_http_lua_ngx_req_get_body_data(lua_State *L)
|
|||
|
||||
for (; cl; cl = cl->next) {
|
||||
dd("body chunk len: %d", (int) ngx_buf_size(cl->buf));
|
||||
len += cl->buf->last - cl->buf->pos;
|
||||
size = cl->buf->last - cl->buf->pos;
|
||||
if (max > 0 && (len + size > max)) {
|
||||
len = max;
|
||||
break;
|
||||
}
|
||||
|
||||
len += size;
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
|
|
@ -286,8 +316,15 @@ ngx_http_lua_ngx_req_get_body_data(lua_State *L)
|
|||
buf = (u_char *) lua_newuserdata(L, len);
|
||||
|
||||
p = buf;
|
||||
for (cl = r->request_body->bufs; cl; cl = cl->next) {
|
||||
p = ngx_copy(p, cl->buf->pos, cl->buf->last - cl->buf->pos);
|
||||
rest = len;
|
||||
for (cl = r->request_body->bufs; cl != NULL && rest > 0; cl = cl->next) {
|
||||
size = ngx_buf_size(cl->buf);
|
||||
if (size > rest) { /* reach limit*/
|
||||
size = rest;
|
||||
}
|
||||
|
||||
p = ngx_copy(p, cl->buf->pos, size);
|
||||
rest -= size;
|
||||
}
|
||||
|
||||
lua_pushlstring(L, (char *) buf, len);
|
||||
|
|
@ -312,6 +349,23 @@ ngx_http_lua_ngx_req_get_body_file(lua_State *L)
|
|||
return luaL_error(L, "request object not found");
|
||||
}
|
||||
|
||||
/* http2 read body may break http2 stream process */
|
||||
#if (NGX_HTTP_V2)
|
||||
if (r->main->stream && r->headers_in.content_length_n < 0) {
|
||||
return luaL_error(L, "http2 requests are not supported"
|
||||
" without content-length header");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
if (r->http_version == NGX_HTTP_VERSION_30
|
||||
&& r->headers_in.content_length_n < 0)
|
||||
{
|
||||
return luaL_error(L, "http3 requests are not supported"
|
||||
" without content-length header");
|
||||
}
|
||||
#endif
|
||||
|
||||
ngx_http_lua_check_fake_request(L, r);
|
||||
|
||||
if (r->request_body == NULL || r->request_body->temp_file == NULL) {
|
||||
|
|
|
|||
|
|
@ -140,7 +140,12 @@ ngx_http_lua_rewrite_handler(ngx_http_request_t *r)
|
|||
return NGX_DONE;
|
||||
}
|
||||
|
||||
/* http2 read body may break http2 stream process */
|
||||
#if (NGX_HTTP_V2)
|
||||
if (llcf->force_read_body && !ctx->read_body_done && !r->main->stream) {
|
||||
#else
|
||||
if (llcf->force_read_body && !ctx->read_body_done) {
|
||||
#endif
|
||||
r->request_body_in_single_buf = 1;
|
||||
r->request_body_in_persistent_file = 1;
|
||||
r->request_body_in_clean_file = 1;
|
||||
|
|
|
|||
|
|
@ -102,8 +102,13 @@ ngx_http_lua_server_rewrite_handler(ngx_http_request_t *r)
|
|||
return NGX_DONE;
|
||||
}
|
||||
|
||||
/* TODO: lscf do not have force_read_body */
|
||||
/* TODO: lscf do not have force_read_body
|
||||
* http2 read body may break http2 stream process */
|
||||
#if (NGX_HTTP_V2)
|
||||
if (llcf->force_read_body && !ctx->read_body_done && !r->main->stream) {
|
||||
#else
|
||||
if (llcf->force_read_body && !ctx->read_body_done) {
|
||||
#endif
|
||||
r->request_body_in_single_buf = 1;
|
||||
r->request_body_in_persistent_file = 1;
|
||||
r->request_body_in_clean_file = 1;
|
||||
|
|
|
|||
|
|
@ -198,9 +198,6 @@ ngx_http_lua_shdict_lookup(ngx_shm_zone_t *shm_zone, ngx_uint_t hash,
|
|||
rc = ngx_memn2cmp(kdata, sd->data, klen, (size_t) sd->key_len);
|
||||
|
||||
if (rc == 0) {
|
||||
ngx_queue_remove(&sd->queue);
|
||||
ngx_queue_insert_head(&ctx->sh->lru_queue, &sd->queue);
|
||||
|
||||
*sdp = sd;
|
||||
|
||||
dd("node expires: %lld", (long long) sd->expires);
|
||||
|
|
@ -219,6 +216,9 @@ ngx_http_lua_shdict_lookup(ngx_shm_zone_t *shm_zone, ngx_uint_t hash,
|
|||
}
|
||||
}
|
||||
|
||||
ngx_queue_remove(&sd->queue);
|
||||
ngx_queue_insert_head(&ctx->sh->lru_queue, &sd->queue);
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
|
@ -654,7 +654,7 @@ ngx_http_lua_shared_dict_get(ngx_shm_zone_t *zone, u_char *key_data,
|
|||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ngx_memcpy(&value->value.b, data, len);
|
||||
ngx_memcpy(&value->value.n, data, len);
|
||||
break;
|
||||
|
||||
case SHDICT_TBOOLEAN:
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ static void ngx_http_lua_socket_dummy_handler(ngx_http_request_t *r,
|
|||
ngx_http_lua_socket_tcp_upstream_t *u);
|
||||
static int ngx_http_lua_socket_tcp_receive_helper(ngx_http_request_t *r,
|
||||
ngx_http_lua_socket_tcp_upstream_t *u, lua_State *L);
|
||||
static void ngx_http_lua_socket_tcp_read_prepare(ngx_http_request_t *r,
|
||||
ngx_http_lua_socket_tcp_upstream_t *u, void *data, lua_State *L);
|
||||
static ngx_int_t ngx_http_lua_socket_tcp_read(ngx_http_request_t *r,
|
||||
ngx_http_lua_socket_tcp_upstream_t *u);
|
||||
static int ngx_http_lua_socket_tcp_receive_retval_handler(ngx_http_request_t *r,
|
||||
|
|
@ -863,7 +865,9 @@ ngx_http_lua_socket_tcp_bind(lua_State *L)
|
|||
| NGX_HTTP_LUA_CONTEXT_ACCESS
|
||||
| NGX_HTTP_LUA_CONTEXT_CONTENT
|
||||
| NGX_HTTP_LUA_CONTEXT_TIMER
|
||||
| NGX_HTTP_LUA_CONTEXT_SSL_CERT);
|
||||
| NGX_HTTP_LUA_CONTEXT_SSL_CERT
|
||||
| NGX_HTTP_LUA_CONTEXT_SSL_SESS_FETCH
|
||||
| NGX_HTTP_LUA_CONTEXT_SSL_CLIENT_HELLO);
|
||||
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
|
||||
|
|
@ -2163,8 +2167,6 @@ ngx_http_lua_socket_tcp_receive_helper(ngx_http_request_t *r,
|
|||
ngx_http_lua_ctx_t *ctx;
|
||||
ngx_http_lua_co_ctx_t *coctx;
|
||||
|
||||
u->input_filter_ctx = u;
|
||||
|
||||
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
||||
|
||||
if (u->bufs_in == NULL) {
|
||||
|
|
@ -2193,6 +2195,8 @@ ngx_http_lua_socket_tcp_receive_helper(ngx_http_request_t *r,
|
|||
u->read_waiting = 0;
|
||||
u->read_co_ctx = NULL;
|
||||
|
||||
ngx_http_lua_socket_tcp_read_prepare(r, u, u, L);
|
||||
|
||||
rc = ngx_http_lua_socket_tcp_read(r, u);
|
||||
|
||||
if (rc == NGX_ERROR) {
|
||||
|
|
@ -2409,7 +2413,7 @@ ngx_http_lua_socket_tcp_receive(lua_State *L)
|
|||
case LUA_TNUMBER:
|
||||
bytes = lua_tointeger(L, 2);
|
||||
if (bytes < 0) {
|
||||
return luaL_argerror(L, 2, "bad pattern argument");
|
||||
return luaL_argerror(L, 2, "bad number argument");
|
||||
}
|
||||
|
||||
#if 1
|
||||
|
|
@ -2426,7 +2430,7 @@ ngx_http_lua_socket_tcp_receive(lua_State *L)
|
|||
break;
|
||||
|
||||
default:
|
||||
return luaL_argerror(L, 2, "bad pattern argument");
|
||||
return luaL_argerror(L, 2, "bad argument");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2514,6 +2518,87 @@ ngx_http_lua_socket_read_any(void *data, ssize_t bytes)
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_http_lua_socket_tcp_read_prepare(ngx_http_request_t *r,
|
||||
ngx_http_lua_socket_tcp_upstream_t *u, void *data, lua_State *L)
|
||||
{
|
||||
ngx_http_lua_ctx_t *ctx;
|
||||
ngx_chain_t *new_cl;
|
||||
ngx_buf_t *b;
|
||||
off_t size;
|
||||
|
||||
ngx_http_lua_socket_compiled_pattern_t *cp;
|
||||
|
||||
/* input_filter_ctx doesn't change, no need recovering */
|
||||
if (u->input_filter_ctx == data) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* last input_filter_ctx is null or upstream, no data pending */
|
||||
if (u->input_filter_ctx == NULL || u->input_filter_ctx == u) {
|
||||
u->input_filter_ctx = data;
|
||||
return;
|
||||
}
|
||||
|
||||
/* compiled pattern may be with data pending */
|
||||
|
||||
cp = u->input_filter_ctx;
|
||||
u->input_filter_ctx = data;
|
||||
|
||||
cp->upstream = NULL;
|
||||
|
||||
/* no data pending */
|
||||
if (cp->state <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
b = &u->buffer;
|
||||
|
||||
if (b->pos - b->start >= cp->state) {
|
||||
dd("pending data in one buffer");
|
||||
|
||||
b->pos -= cp->state;
|
||||
|
||||
u->buf_in->buf->pos = b->pos;
|
||||
u->buf_in->buf->last = b->pos;
|
||||
|
||||
/* reset dfa state for future matching */
|
||||
cp->state = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
dd("pending data in multiple buffers");
|
||||
|
||||
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
||||
|
||||
size = ngx_buf_size(b);
|
||||
|
||||
new_cl =
|
||||
ngx_http_lua_chain_get_free_buf(r->connection->log, r->pool,
|
||||
&ctx->free_recv_bufs,
|
||||
cp->state + size);
|
||||
|
||||
if (new_cl == NULL) {
|
||||
luaL_error(L, "no memory");
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_memcpy(b, new_cl->buf, sizeof(ngx_buf_t));
|
||||
|
||||
b->last = ngx_copy(b->last, cp->pattern.data, cp->state);
|
||||
b->last = ngx_copy(b->last, u->buf_in->buf->pos, size);
|
||||
|
||||
u->buf_in->next = ctx->free_recv_bufs;
|
||||
ctx->free_recv_bufs = u->buf_in;
|
||||
|
||||
u->bufs_in = new_cl;
|
||||
u->buf_in = new_cl;
|
||||
|
||||
/* reset dfa state for future matching */
|
||||
cp->state = 0;
|
||||
}
|
||||
|
||||
|
||||
static ngx_int_t
|
||||
ngx_http_lua_socket_tcp_read(ngx_http_request_t *r,
|
||||
ngx_http_lua_socket_tcp_upstream_t *u)
|
||||
|
|
@ -3261,7 +3346,7 @@ ngx_http_lua_socket_tcp_settimeouts(lua_State *L)
|
|||
n = lua_gettop(L);
|
||||
|
||||
if (n != 4) {
|
||||
return luaL_error(L, "ngx.socket settimeout: expecting 4 arguments "
|
||||
return luaL_error(L, "ngx.socket settimeouts: expecting 4 arguments "
|
||||
"(including the object) but seen %d", lua_gettop(L));
|
||||
}
|
||||
|
||||
|
|
@ -4243,6 +4328,11 @@ ngx_http_lua_socket_tcp_finalize(ngx_http_request_t *r,
|
|||
ngx_http_lua_socket_tcp_finalize_read_part(r, u);
|
||||
ngx_http_lua_socket_tcp_finalize_write_part(r, u);
|
||||
|
||||
if (u->input_filter_ctx != NULL && u->input_filter_ctx != u) {
|
||||
((ngx_http_lua_socket_compiled_pattern_t *)
|
||||
u->input_filter_ctx)->upstream = NULL;
|
||||
}
|
||||
|
||||
if (u->raw_downstream || u->body_downstream) {
|
||||
u->peer.connection = NULL;
|
||||
return;
|
||||
|
|
@ -4496,7 +4586,7 @@ ngx_http_lua_socket_receiveuntil_iterator(lua_State *L)
|
|||
|
||||
n = lua_gettop(L);
|
||||
if (n > 1) {
|
||||
return luaL_error(L, "expecting 0 or 1 arguments, "
|
||||
return luaL_error(L, "expecting 0 or 1 argument, "
|
||||
"but seen %d", n);
|
||||
}
|
||||
|
||||
|
|
@ -4559,8 +4649,6 @@ ngx_http_lua_socket_receiveuntil_iterator(lua_State *L)
|
|||
(u_char *) lua_tolstring(L, lua_upvalueindex(2),
|
||||
&cp->pattern.len);
|
||||
|
||||
u->input_filter_ctx = cp;
|
||||
|
||||
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
|
||||
|
||||
if (u->bufs_in == NULL) {
|
||||
|
|
@ -4587,6 +4675,8 @@ ngx_http_lua_socket_receiveuntil_iterator(lua_State *L)
|
|||
u->read_waiting = 0;
|
||||
u->read_co_ctx = NULL;
|
||||
|
||||
ngx_http_lua_socket_tcp_read_prepare(r, u, cp, L);
|
||||
|
||||
rc = ngx_http_lua_socket_tcp_read(r, u);
|
||||
|
||||
if (rc == NGX_ERROR) {
|
||||
|
|
@ -4915,13 +5005,24 @@ ngx_http_lua_socket_cleanup_compiled_pattern(lua_State *L)
|
|||
{
|
||||
ngx_http_lua_socket_compiled_pattern_t *cp;
|
||||
|
||||
ngx_http_lua_dfa_edge_t *edge, *p;
|
||||
unsigned i;
|
||||
ngx_http_lua_socket_tcp_upstream_t *u;
|
||||
ngx_http_lua_dfa_edge_t *edge, *p;
|
||||
unsigned i;
|
||||
|
||||
dd("cleanup compiled pattern");
|
||||
|
||||
cp = lua_touserdata(L, 1);
|
||||
if (cp == NULL || cp->recovering == NULL) {
|
||||
if (cp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u = cp->upstream;
|
||||
if (u != NULL) {
|
||||
ngx_http_lua_socket_tcp_read_prepare(u->request, u, NULL, L);
|
||||
u->input_filter_ctx = NULL;
|
||||
}
|
||||
|
||||
if (cp->recovering == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -4975,7 +5076,7 @@ ngx_http_lua_req_socket(lua_State *L)
|
|||
lua_pop(L, 1);
|
||||
|
||||
} else {
|
||||
return luaL_error(L, "expecting zero arguments, but got %d",
|
||||
return luaL_error(L, "expecting 0 or 1 argument, but got %d",
|
||||
lua_gettop(L));
|
||||
}
|
||||
|
||||
|
|
@ -4998,6 +5099,12 @@ ngx_http_lua_req_socket(lua_State *L)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
if (r->http_version == NGX_HTTP_VERSION_30) {
|
||||
return luaL_error(L, "http v3 not supported yet");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!raw && r->headers_in.chunked) {
|
||||
lua_pushnil(L);
|
||||
lua_pushliteral(L, "chunked request bodies not supported yet");
|
||||
|
|
@ -5494,6 +5601,7 @@ ngx_http_lua_socket_tcp_setkeepalive(lua_State *L)
|
|||
if (c->read->ready) {
|
||||
rc = ngx_http_lua_socket_keepalive_close_handler(c->read);
|
||||
if (rc != NGX_OK) {
|
||||
ngx_http_lua_socket_tcp_finalize(r, u);
|
||||
lua_pushnil(L);
|
||||
lua_pushliteral(L, "connection in dubious state");
|
||||
return 2;
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ ngx_http_lua_ssl_client_hello_aborted(void *data)
|
|||
{
|
||||
ngx_http_lua_ssl_ctx_t *cctx = data;
|
||||
|
||||
dd("lua ssl client hello done");
|
||||
dd("lua ssl client hello aborted");
|
||||
|
||||
if (cctx->done) {
|
||||
/* completed successfully already */
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ ngx_str_t ngx_http_lua_patch_method =
|
|||
ngx_str_t ngx_http_lua_trace_method =
|
||||
ngx_http_lua_method_name("TRACE");
|
||||
|
||||
ngx_str_t host_header = ngx_string("host");
|
||||
|
||||
|
||||
static ngx_str_t ngx_http_lua_content_length_header_key =
|
||||
ngx_string("Content-Length");
|
||||
|
|
@ -1667,6 +1669,9 @@ ngx_http_lua_copy_request_headers(ngx_http_request_t *sr,
|
|||
|
||||
clh->hash = ngx_http_lua_content_length_hash;
|
||||
clh->key = ngx_http_lua_content_length_header_key;
|
||||
#if defined(nginx_version) && nginx_version >= 1023000
|
||||
clh->next = NULL;
|
||||
#endif
|
||||
clh->lowcase_key = ngx_pnalloc(sr->pool, clh->key.len);
|
||||
if (clh->lowcase_key == NULL) {
|
||||
return NGX_ERROR;
|
||||
|
|
@ -1696,6 +1701,17 @@ ngx_http_lua_copy_request_headers(ngx_http_request_t *sr,
|
|||
part = &pr->headers_in.headers.part;
|
||||
header = part->elts;
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
if (pr->headers_in.server.data != NULL) {
|
||||
if (ngx_http_lua_set_input_header(sr, host_header,
|
||||
pr->headers_in.server, 0)
|
||||
== NGX_ERROR)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; /* void */; i++) {
|
||||
|
||||
if (i >= part->nelts) {
|
||||
|
|
|
|||
|
|
@ -70,6 +70,18 @@ ngx_http_lua_ffi_var_get(ngx_http_request_t *r, u_char *name_data,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
if (name_len == 9
|
||||
&& r->http_version == NGX_HTTP_VERSION_30
|
||||
&& ngx_strncasecmp(name_data, (u_char *) "http_host", 9) == 0
|
||||
&& r->headers_in.server.data != NULL)
|
||||
{
|
||||
*value = r->headers_in.server.data;
|
||||
*value_len = r->headers_in.server.len;
|
||||
return NGX_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
hash = ngx_hash_strlow(lowcase_buf, name_data, name_len);
|
||||
|
||||
name.data = lowcase_buf;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ typedef struct {
|
|||
ngx_http_lua_co_ctx_t *wait_co_ctx;
|
||||
int n_args;
|
||||
int rc;
|
||||
int is_abort:1;
|
||||
ngx_uint_t is_abort:1;
|
||||
} ngx_http_lua_worker_thread_ctx_t;
|
||||
|
||||
|
||||
|
|
@ -157,15 +157,6 @@ ngx_http_lua_get_task_ctx(lua_State *L, ngx_http_request_t *r)
|
|||
ngx_http_lua_inject_shdict_api(lmcf, vm);
|
||||
lua_setglobal(vm, "ngx");
|
||||
|
||||
/* inject API via ffi */
|
||||
lua_getglobal(vm, "require");
|
||||
lua_pushstring(vm, "resty.core.regex");
|
||||
if (lua_pcall(vm, 1, 0, 0) != 0) {
|
||||
lua_close(vm);
|
||||
ngx_free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lua_getglobal(vm, "require");
|
||||
lua_pushstring(vm, "resty.core.hash");
|
||||
if (lua_pcall(vm, 1, 0, 0) != 0) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ $ENV{TEST_NGINX_MYSQL_PORT} ||= 3306;
|
|||
|
||||
our $http_config = <<'_EOC_';
|
||||
# lua-resty-string is required for lua-resty-mysql
|
||||
lua_package_path "../lua-resty-mysql/lib/?.lua;../lua-resty-string/lib/?.lua;;";
|
||||
lua_package_path "../lua-resty-rsa/lib/?.lua;../lua-resty-mysql/lib/?.lua;../lua-resty-string/lib/?.lua;;";
|
||||
_EOC_
|
||||
|
||||
no_shuffle();
|
||||
|
|
|
|||
16
t/001-set.t
16
t/001-set.t
|
|
@ -389,8 +389,8 @@ GET /lua
|
|||
GET /lua
|
||||
--- response_body_like: 500 Internal Server Error
|
||||
--- error_code: 500
|
||||
--- error_log
|
||||
API disabled in the context of set_by_lua*
|
||||
--- error_log eval
|
||||
qr/(?:API disabled in the context of set_by_lua\*|http3 requests are not supported without content-length header)/ms
|
||||
|
||||
|
||||
|
||||
|
|
@ -404,8 +404,16 @@ API disabled in the context of set_by_lua*
|
|||
GET /lua
|
||||
--- response_body_like: 500 Internal Server Error
|
||||
--- error_code: 500
|
||||
--- error_log
|
||||
API disabled in the context of set_by_lua*
|
||||
--- error_log eval
|
||||
my $err_log;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$err_log = "http v3 not supported yet";
|
||||
} else {
|
||||
$err_log = "API disabled in the context of set_by_lua*";
|
||||
}
|
||||
|
||||
$err_log;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ GET /lua
|
|||
--- error_log
|
||||
attempt to set status 404 via ngx.exit after sending out the response status 200
|
||||
--- no_error_log
|
||||
alert
|
||||
[alert]
|
||||
--- response_body
|
||||
hi
|
||||
|
||||
|
|
@ -123,6 +123,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}
|
||||
--- http_config eval
|
||||
"
|
||||
lua_package_cpath '$::LuaCpath';
|
||||
|
|
@ -195,6 +196,7 @@ Logged in 56
|
|||
|
||||
|
||||
=== TEST 7: working with ngx_auth_request (simplest form)
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- http_config eval
|
||||
"
|
||||
lua_package_cpath '$::LuaCpath';
|
||||
|
|
@ -267,6 +269,7 @@ Logged in 56
|
|||
|
||||
|
||||
=== TEST 8: working with ngx_auth_request
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- http_config eval
|
||||
"
|
||||
lua_package_cpath '$::LuaCpath';
|
||||
|
|
@ -771,6 +774,8 @@ GET /t
|
|||
--- response_body
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- curl_error
|
||||
curl: (95) HTTP/3 stream 0 reset by server
|
||||
|
||||
|
||||
|
||||
|
|
@ -787,6 +792,8 @@ GET /t
|
|||
--- response_body
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- curl_error
|
||||
curl: (95) HTTP/3 stream 0 reset by server
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -270,3 +270,22 @@ Expect: 100-Continue
|
|||
http finalize request: 500, "/echo_body?" a:1, c:2
|
||||
http finalize request: 500, "/echo_body?" a:1, c:0
|
||||
--- log_level: debug
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
=== TEST 13: test reading the first n bytes of request body
|
||||
--- config
|
||||
location /echo_body {
|
||||
lua_need_request_body on;
|
||||
content_by_lua_block {
|
||||
local data = ngx.req.get_body_data(1)
|
||||
ngx.say(data)
|
||||
}
|
||||
}
|
||||
--- request
|
||||
POST /echo_body
|
||||
hello
|
||||
--- response_body
|
||||
h
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
|
|
|||
42
t/014-bugs.t
42
t/014-bugs.t
|
|
@ -194,6 +194,14 @@ Hi"
|
|||
|
||||
=== TEST 8: github issue 37: header bug
|
||||
https://github.com/chaoslawful/lua-nginx-module/issues/37
|
||||
|
||||
https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2
|
||||
Just as in HTTP/1.x, header field names are strings of ASCII
|
||||
characters that are compared in a case-insensitive fashion. However,
|
||||
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
|
||||
|
||||
--- config
|
||||
location /sub {
|
||||
content_by_lua '
|
||||
|
|
@ -220,8 +228,17 @@ https://github.com/chaoslawful/lua-nginx-module/issues/37
|
|||
--- request
|
||||
GET /lua
|
||||
--- raw_response_headers_like eval
|
||||
".*Set-Cookie: TestCookie1=foo\r
|
||||
my $headers;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$headers = ".*set-cookie: TestCookie1=foo\r
|
||||
set-cookie: TestCookie2=bar.*"
|
||||
} else {
|
||||
$headers = ".*Set-Cookie: TestCookie1=foo\r
|
||||
Set-Cookie: TestCookie2=bar.*"
|
||||
}
|
||||
|
||||
$headers;
|
||||
|
||||
|
||||
|
||||
|
|
@ -714,6 +731,7 @@ Content-Type: application/json; charset=utf-8
|
|||
|
||||
|
||||
=== TEST 32: hang on upstream_next (from kindy)
|
||||
--- no_http2
|
||||
--- no_check_leak
|
||||
--- http_config
|
||||
upstream xx {
|
||||
|
|
@ -770,6 +788,10 @@ eof found in body stream
|
|||
|
||||
=== TEST 34: testing a segfault when using ngx_poll_module + ngx_resolver
|
||||
See more details here: http://mailman.nginx.org/pipermail/nginx-devel/2013-January/003275.html
|
||||
|
||||
http3 may cache the dns result.
|
||||
so need to skip for http3
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- config
|
||||
location /t {
|
||||
set $myserver nginx.org;
|
||||
|
|
@ -786,6 +808,8 @@ See more details here: http://mailman.nginx.org/pipermail/nginx-devel/2013-Janua
|
|||
[alert]
|
||||
--- error_log eval
|
||||
qr/(?:send|recv)\(\) failed \(\d+: Connection refused\) while resolving/
|
||||
--- curl_error eval
|
||||
qr/curl: \(28\) Operation timed out after \d+ milliseconds with 0 bytes received/
|
||||
|
||||
|
||||
|
||||
|
|
@ -861,6 +885,7 @@ GET /t
|
|||
--- no_error_log
|
||||
[error]
|
||||
--- timeout: 10
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -868,7 +893,7 @@ GET /t
|
|||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';
|
||||
server {
|
||||
listen 12354;
|
||||
listen \$TEST_NGINX_RAND_PORT_1;
|
||||
|
||||
location = /t {
|
||||
echo 'args: \$args';
|
||||
|
|
@ -878,7 +903,7 @@ GET /t
|
|||
--- config
|
||||
location = /t {
|
||||
set $args "foo=1&bar=2";
|
||||
proxy_pass http://127.0.0.1:12354;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_1;
|
||||
}
|
||||
|
||||
--- request
|
||||
|
|
@ -1281,8 +1306,17 @@ location /t {
|
|||
--- response_body
|
||||
Hello world
|
||||
--- shutdown_error_log eval
|
||||
qr|failed to read a line: closed|
|
||||
my $expr;
|
||||
|
||||
if ($ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$expr = qr|lua close the global Lua VM|
|
||||
} else {
|
||||
$expr = qr|failed to read a line: closed|
|
||||
}
|
||||
|
||||
$expr;
|
||||
--- timeout: 1.2
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -233,6 +233,8 @@ GET /t
|
|||
--- error_code: 101
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ GET /read
|
|||
Content-Length: 3
|
||||
--- response_body chop
|
||||
Hel
|
||||
--- skip_eval: 3:defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})
|
||||
|
||||
|
||||
|
||||
|
|
@ -113,8 +114,16 @@ Hello
|
|||
}
|
||||
--- request
|
||||
GET /read
|
||||
--- raw_response_headers_like chomp
|
||||
X-Foo: a\r\n.*?X-Foo: bc\r\n
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
$headers = qr/x-foo: a\r\n.*?x-foo: bc\r\n/
|
||||
} else {
|
||||
$headers = qr/X-Foo: a\r\n.*?X-Foo: bc\r\n/
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body
|
||||
Hello
|
||||
|
||||
|
|
@ -184,8 +193,16 @@ Hello
|
|||
}
|
||||
--- request
|
||||
GET /read
|
||||
--- raw_response_headers_like chomp
|
||||
X-Foo: a\r\n.*?X-Foo: abc\r\n
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
$headers = "x-foo: a\r\n.*?x-foo: abc\r\n"
|
||||
} else {
|
||||
$headers = "X-Foo: a\r\n.*?X-Foo: abc\r\n"
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body
|
||||
Hello
|
||||
|
||||
|
|
@ -203,8 +220,17 @@ Hello
|
|||
--- request
|
||||
GET /lua
|
||||
--- raw_response_headers_like eval
|
||||
".*Foo: a\r
|
||||
Foo: b.*"
|
||||
my $headers;
|
||||
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
$headers = ".*foo: a\r
|
||||
foo: b.*";
|
||||
} else {
|
||||
$headers = ".*Foo: a\r
|
||||
Foo: b.*";
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body
|
||||
|
||||
|
||||
|
|
@ -222,8 +248,17 @@ Foo: b.*"
|
|||
--- request
|
||||
GET /lua
|
||||
--- raw_response_headers_like eval
|
||||
".*Foo: a\r
|
||||
Foo: b.*"
|
||||
my $headers;
|
||||
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
$headers = ".*foo: a\r
|
||||
foo: b.*";
|
||||
} else {
|
||||
$headers = ".*Foo: a\r
|
||||
Foo: b.*";
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body
|
||||
|
||||
|
||||
|
|
@ -278,7 +313,7 @@ hello
|
|||
--- error_log
|
||||
attempt to set ngx.header.HEADER after sending out response headers
|
||||
--- no_error_log eval
|
||||
["alert", "warn"]
|
||||
["[alert]", "[warn]"]
|
||||
|
||||
|
||||
|
||||
|
|
@ -1071,8 +1106,8 @@ GET /t
|
|||
--- more_headers
|
||||
Foo: bar
|
||||
Bah: baz
|
||||
--- response_headers
|
||||
Location: http://localhost:$ServerPort/t/
|
||||
--- response_headers_like
|
||||
Location: https?://localhost:\d+/t/
|
||||
--- response_body_like: 301 Moved Permanently
|
||||
--- error_code: 301
|
||||
--- no_error_log
|
||||
|
|
@ -1094,8 +1129,8 @@ GET /t
|
|||
Foo: bar
|
||||
Bah: baz
|
||||
--- response_body_like: 301 Moved Permanently
|
||||
--- response_headers
|
||||
Location: http://localhost:$ServerPort/t/
|
||||
--- response_headers_like
|
||||
Location: https?://localhost:\d+/t/
|
||||
--- error_code: 301
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
@ -1115,8 +1150,8 @@ GET /t
|
|||
--- more_headers
|
||||
Foo: bar
|
||||
Bah: baz
|
||||
--- response_headers
|
||||
Location: http://localhost:$ServerPort/t/
|
||||
--- response_headers_like
|
||||
Location: https?://localhost:\d+/t/
|
||||
Foo: /t/
|
||||
--- response_body_like: 301 Moved Permanently
|
||||
--- error_code: 301
|
||||
|
|
@ -1139,8 +1174,8 @@ GET /t
|
|||
--- more_headers
|
||||
Foo: bar
|
||||
Bah: baz
|
||||
--- response_headers
|
||||
Location: http://localhost:$ServerPort/t/
|
||||
--- response_headers_like
|
||||
Location: https?://localhost:\d+/t/
|
||||
Foo: /t/
|
||||
--- response_body_like: 301 Moved Permanently
|
||||
--- error_code: 301
|
||||
|
|
@ -1159,8 +1194,16 @@ Foo: /t/
|
|||
}
|
||||
--- request
|
||||
GET /lua
|
||||
--- raw_response_headers_like chop
|
||||
cache-Control: private
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
$headers = "cache-control: private"
|
||||
} else {
|
||||
$headers = "cache-Control: private"
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body
|
||||
Cache-Control: private
|
||||
|
||||
|
|
@ -1509,6 +1552,7 @@ hi
|
|||
--- error_log
|
||||
my Transfer-Encoding: chunked
|
||||
my transfer-encoding: chunked
|
||||
--- skip_eval: 6:defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})
|
||||
|
||||
|
||||
|
||||
|
|
@ -2165,8 +2209,8 @@ upstream prematurely closed connection while sending to client
|
|||
Foo
|
||||
--- request
|
||||
GET /a.txt
|
||||
--- raw_response_headers_like chomp
|
||||
Age: \d\r\n
|
||||
--- raw_response_headers_like eval
|
||||
qr/^(a|A)ge: \d\r\n/ms
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -2196,8 +2240,8 @@ Age: \d\r\n
|
|||
Foo
|
||||
--- request
|
||||
GET /test/a.txt
|
||||
--- raw_response_headers_like chomp
|
||||
Age: \d\r\n
|
||||
--- raw_response_headers_like eval
|
||||
qr/^(a|A)ge: \d\r\n/ms
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
|
|||
|
|
@ -1227,6 +1227,8 @@ F(ngx_http_finalize_request) {
|
|||
--- error_code
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- curl_error eval
|
||||
qr{(\Qcurl: (52) Empty reply from server\E|\Qcurl: (95) HTTP/3 stream 0 reset by server\E)}ms
|
||||
|
||||
|
||||
|
||||
|
|
@ -1238,7 +1240,7 @@ F(ngx_http_finalize_request) {
|
|||
|
||||
set $memc_key 'foo';
|
||||
#set $memc_exptime 300;
|
||||
memc_pass 127.0.0.1:19112; #$TEST_NGINX_MEMCACHED_PORT;
|
||||
memc_pass 127.0.0.1:$TEST_NGINX_RAND_PORT_1; #$TEST_NGINX_MEMCACHED_PORT;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1251,7 +1253,7 @@ F(ngx_http_finalize_request) {
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19112
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_1
|
||||
--- tcp_query_len: 9
|
||||
--- tcp_reply eval
|
||||
"VALUE foo 0 1024\r\nhello world"
|
||||
|
|
@ -1308,7 +1310,7 @@ upstream prematurely closed connection
|
|||
|
||||
set $memc_key 'foo';
|
||||
#set $memc_exptime 300;
|
||||
memc_pass 127.0.0.1:19112; #$TEST_NGINX_MEMCACHED_PORT;
|
||||
memc_pass 127.0.0.1:$TEST_NGINX_RAND_PORT_1; #$TEST_NGINX_MEMCACHED_PORT;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1321,7 +1323,7 @@ upstream prematurely closed connection
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19112
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_1
|
||||
--- tcp_no_close
|
||||
--- tcp_reply eval
|
||||
"VALUE foo 0 1024\r\nhello world"
|
||||
|
|
@ -1381,7 +1383,7 @@ upstream timed out
|
|||
|
||||
#proxy_read_timeout 100ms;
|
||||
proxy_buffering on;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1394,7 +1396,7 @@ upstream timed out
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_query_len: 65
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.0 200 OK\r\nContent-Length: 1024\r\n\r\nhello world"
|
||||
|
|
@ -1441,7 +1443,7 @@ upstream prematurely closed connection
|
|||
|
||||
proxy_read_timeout 100ms;
|
||||
proxy_buffering on;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1454,7 +1456,7 @@ upstream prematurely closed connection
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_no_close
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.0 200 OK\r\nContent-Length: 1024\r\n\r\nhello world"
|
||||
|
|
@ -1503,7 +1505,7 @@ upstream timed out
|
|||
|
||||
#proxy_read_timeout 100ms;
|
||||
proxy_buffering on;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1516,7 +1518,7 @@ upstream timed out
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_query_len: 65
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.0 200 OK\r\n\r\nhello world"
|
||||
|
|
@ -1563,7 +1565,7 @@ truncated: false
|
|||
|
||||
proxy_read_timeout 100ms;
|
||||
proxy_buffering on;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1576,7 +1578,7 @@ truncated: false
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_no_close
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.0 200 OK\r\n\r\nhello world"
|
||||
|
|
@ -1626,7 +1628,7 @@ upstream timed out
|
|||
|
||||
#proxy_read_timeout 100ms;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1639,7 +1641,7 @@ upstream timed out
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_query_len: 65
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.0 200 OK\r\n\r\nhello world"
|
||||
|
|
@ -1686,7 +1688,7 @@ truncated: false
|
|||
|
||||
proxy_read_timeout 500ms;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1699,7 +1701,7 @@ truncated: false
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_no_close
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.0 200 OK\r\n\r\nhello world"
|
||||
|
|
@ -1912,7 +1914,7 @@ a client request body is buffered to a temporary file
|
|||
#proxy_read_timeout 100ms;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering on;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1925,7 +1927,7 @@ a client request body is buffered to a temporary file
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_query_len: 65
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\nb\r\nhello world\r"
|
||||
|
|
@ -1975,7 +1977,7 @@ upstream prematurely closed connection
|
|||
#proxy_read_timeout 100ms;
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -1988,7 +1990,7 @@ upstream prematurely closed connection
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_query_len: 65
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\nb\r\nhello world\r"
|
||||
|
|
@ -2036,7 +2038,7 @@ upstream prematurely closed connection
|
|||
proxy_read_timeout 100ms;
|
||||
proxy_buffering on;
|
||||
proxy_http_version 1.1;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -2049,7 +2051,7 @@ upstream prematurely closed connection
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_no_close
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\nb\r\nhello world\r"
|
||||
|
|
@ -2098,7 +2100,7 @@ upstream timed out
|
|||
#proxy_read_timeout 100ms;
|
||||
proxy_buffering on;
|
||||
proxy_http_version 1.1;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -2111,7 +2113,7 @@ upstream timed out
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_no_close
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n0\r\n\r\n"
|
||||
|
|
@ -2156,7 +2158,7 @@ truncated: false
|
|||
#proxy_read_timeout 100ms;
|
||||
proxy_buffering off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -2169,7 +2171,7 @@ truncated: false
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_no_close
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n0\r\n\r\n"
|
||||
|
|
@ -2215,7 +2217,7 @@ truncated: false
|
|||
|
||||
#proxy_read_timeout 100ms;
|
||||
proxy_buffering off;
|
||||
proxy_pass http://127.0.0.1:19113;
|
||||
proxy_pass http://127.0.0.1:$TEST_NGINX_RAND_PORT_2;
|
||||
}
|
||||
|
||||
location /main {
|
||||
|
|
@ -2228,7 +2230,7 @@ truncated: false
|
|||
}
|
||||
--- request
|
||||
GET /main
|
||||
--- tcp_listen: 19113
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_2
|
||||
--- tcp_query_len: 65
|
||||
--- tcp_reply eval
|
||||
"HTTP/1.0 200 OK\r\nContent-Length: 1024\r\n\r\nhello world"
|
||||
|
|
@ -2338,6 +2340,7 @@ hello world
|
|||
nil
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -2622,6 +2625,7 @@ pr: Host: localhost
|
|||
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -2655,6 +2659,7 @@ pr: Host: localhost
|
|||
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,16 @@ GET /read
|
|||
}
|
||||
--- request
|
||||
GET /read
|
||||
--- raw_response_headers_like: Location: /echo\r\n
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$headers = "location: /echo\r\n"
|
||||
} else {
|
||||
$headers = "Location: /echo\r\n"
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body_like: 302 Found
|
||||
--- error_code: 302
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ our $StapScript = $t::StapThread::StapScript;
|
|||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => repeat_each() * (blocks() * 3 - 1);
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
plan(skip_all => "HTTP3 does not support client abort");
|
||||
} elsif (defined $ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
plan(skip_all => "HTTP2 does not support client abort");
|
||||
} else {
|
||||
plan tests => repeat_each() * (blocks() * 3 - 1);
|
||||
}
|
||||
|
||||
$ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8';
|
||||
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= '11211';
|
||||
|
|
|
|||
|
|
@ -187,6 +187,7 @@ ngx.var.uid = res[1].uid;
|
|||
GET /api?uid=32
|
||||
--- response_body
|
||||
Logged in 56
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -258,6 +259,7 @@ ngx.var.uid = res[1].uid;
|
|||
GET /api?uid=32
|
||||
--- response_body
|
||||
Logged in 56
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -342,6 +344,7 @@ GET /api?uid=32
|
|||
Logged in 56
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ our $StapScript = $t::StapThread::StapScript;
|
|||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => repeat_each() * (blocks() * 4 + 15);
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
plan(skip_all => "HTTP3 does not support on_abort");
|
||||
} elsif (defined $ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
plan(skip_all => "HTTP2 does not support on_abort");
|
||||
} else {
|
||||
plan tests => repeat_each() * (blocks() * 4 + 15);
|
||||
}
|
||||
|
||||
$ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8';
|
||||
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= '11211';
|
||||
|
|
|
|||
|
|
@ -119,7 +119,16 @@ GET /read
|
|||
}
|
||||
--- request
|
||||
GET /read
|
||||
--- raw_response_headers_like: Location: /foo\r\n
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
$headers = "location: /foo\r\n"
|
||||
} else {
|
||||
$headers = "Location: /foo\r\n"
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body_like: 302 Found
|
||||
--- error_code: 302
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ Expect: 100-Continue
|
|||
[alert]
|
||||
[error]
|
||||
http finalize request: 500, "/test?" a:1, c:0
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
# vim:set ft= ts=4 sw=4 et fdm=marker:
|
||||
|
||||
use Test::Nginx::Socket::Lua;
|
||||
our $SkipReason;
|
||||
|
||||
BEGIN {
|
||||
if ($ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$SkipReason = "http3 does not support ngx.req.socket";
|
||||
}
|
||||
}
|
||||
|
||||
use Test::Nginx::Socket::Lua $SkipReason ? (skip_all => $SkipReason) : ();
|
||||
|
||||
repeat_each(2);
|
||||
|
||||
|
|
|
|||
|
|
@ -170,3 +170,26 @@ Expect: 100-Continue
|
|||
http finalize request: 500, "/echo_body?" a:1, c:2
|
||||
http finalize request: 500, "/echo_body?" a:1, c:0
|
||||
--- log_level: debug
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
=== TEST 9: test HTTP2 reading request body was disabled
|
||||
--- config
|
||||
location /echo_body {
|
||||
lua_need_request_body on;
|
||||
rewrite_by_lua_block {
|
||||
ngx.print(ngx.var.request_body or "nil")
|
||||
}
|
||||
content_by_lua 'ngx.exit(ngx.OK)';
|
||||
}
|
||||
--- http2
|
||||
--- request eval
|
||||
"POST /echo_body
|
||||
hello\x00\x01\x02
|
||||
world\x03\x04\xff"
|
||||
--- more_headers
|
||||
Content-Length:
|
||||
--- response_body eval
|
||||
"nil"
|
||||
--- no_error_log
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ bad argument #1 to 'sleep'
|
|||
|
||||
|
||||
=== TEST 5: sleep 0.5 - multi-times
|
||||
--- quic_max_idle_timeout: 1.0
|
||||
--- config
|
||||
location /test {
|
||||
rewrite_by_lua '
|
||||
|
|
@ -135,6 +136,7 @@ lua sleep timer expired: "/test?"
|
|||
|
||||
|
||||
=== TEST 6: sleep 0.5 - interleaved by ngx.say() - ended by ngx.sleep
|
||||
--- quic_max_idle_timeout: 2.05
|
||||
--- config
|
||||
location /test {
|
||||
rewrite_by_lua '
|
||||
|
|
@ -163,6 +165,7 @@ lua sleep timer expired: "/test?"
|
|||
|
||||
|
||||
=== TEST 7: sleep 0.5 - interleaved by ngx.say() - not ended by ngx.sleep
|
||||
--- quic_max_idle_timeout: 0.85
|
||||
--- config
|
||||
location /test {
|
||||
rewrite_by_lua '
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ received: OK
|
|||
|
||||
|
||||
=== TEST 3: upstream sockets close prematurely
|
||||
--- no_http3
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -253,6 +254,7 @@ done
|
|||
|
||||
|
||||
=== TEST 4: http keepalive
|
||||
--- no_http3
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -330,6 +332,7 @@ done
|
|||
|
||||
|
||||
=== TEST 5: lua_socket_keepalive_timeout
|
||||
--- quic_max_idle_timeout: 1.1
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -409,6 +412,7 @@ qr/lua tcp socket connection pool size: 30\b/]
|
|||
|
||||
|
||||
=== TEST 6: lua_socket_pool_size
|
||||
--- quic_max_idle_timeout: 1.1
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -489,6 +493,7 @@ qr/lua tcp socket connection pool size: 1\b/]
|
|||
|
||||
|
||||
=== TEST 7: "lua_socket_keepalive_timeout 0" means unlimited
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -571,6 +576,7 @@ lua tcp socket keepalive timeout: unlimited
|
|||
|
||||
|
||||
=== TEST 8: setkeepalive(timeout) overrides lua_socket_keepalive_timeout
|
||||
--- quic_max_idle_timeout: 1.1
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -650,6 +656,7 @@ qr/lua tcp socket connection pool size: 30\b/]
|
|||
|
||||
|
||||
=== TEST 9: sock:setkeepalive(timeout, size) overrides lua_socket_pool_size
|
||||
--- quic_max_idle_timeout: 1.1
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -730,6 +737,7 @@ qr/lua tcp socket connection pool size: 25\b/]
|
|||
|
||||
|
||||
=== TEST 10: sock:keepalive_timeout(0) means unlimited
|
||||
--- quic_max_idle_timeout: 1.1
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ BEGIN {
|
|||
$ENV{MOCKEAGAIN} = 'w';
|
||||
}
|
||||
|
||||
delete($ENV{TEST_NGINX_USE_HTTP2});
|
||||
$ENV{TEST_NGINX_EVENT_TYPE} = 'poll';
|
||||
$ENV{MOCKEAGAIN_WRITE_TIMEOUT_PATTERN} = 'get helloworld';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ failed to receive a line: closed []
|
|||
close: 1 nil
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -155,6 +156,7 @@ failed to receive a line: closed [foo]
|
|||
closed
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -197,6 +199,7 @@ connected: nil
|
|||
failed to send request: closed
|
||||
--- error_log
|
||||
attempt to send data on a closed socket:
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -521,6 +524,7 @@ failed to receive a line: closed
|
|||
close: 1 nil
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -591,6 +595,7 @@ close: 1 nil
|
|||
"
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -672,6 +677,7 @@ close: 1 nil
|
|||
"
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -749,6 +755,7 @@ close: 1 nil
|
|||
"
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -827,6 +834,7 @@ close: 1 nil
|
|||
"
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -898,6 +906,7 @@ failed to receive a line: closed []
|
|||
close: 1 nil
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -967,6 +976,7 @@ failed to receive a line: closed []
|
|||
close: 1 nil
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1077,6 +1087,7 @@ close: 1 nil
|
|||
"
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1521,6 +1532,7 @@ GET /t
|
|||
2: close: 1 nil
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1593,6 +1605,7 @@ failed to receive a line: closed []
|
|||
close: 1 nil
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1654,6 +1667,9 @@ GET /t
|
|||
--- ignore_response
|
||||
--- error_log
|
||||
bad argument #1 to 'send' (bad data type nil found)
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1715,6 +1731,9 @@ GET /t
|
|||
--- ignore_response
|
||||
--- error_log
|
||||
bad argument #1 to 'send' (bad data type boolean found)
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1776,6 +1795,9 @@ GET /t
|
|||
--- ignore_response
|
||||
--- error_log
|
||||
bad argument #1 to 'send' (bad data type userdata found)
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1845,6 +1867,7 @@ subrequest: 200, OK\r
|
|||
"
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1916,6 +1939,7 @@ close: 1 nil
|
|||
--- no_error_log
|
||||
[error]
|
||||
--- SKIP
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1976,6 +2000,7 @@ receive(0): []
|
|||
close: 1 nil
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -2036,6 +2061,7 @@ send(""): 0
|
|||
close: 1 nil
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -2092,6 +2118,7 @@ qr/runtime error: rewrite_by_lua\(nginx\.conf:\d+\):7: bad request/
|
|||
|
||||
--- no_error_log
|
||||
[alert]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -2151,6 +2178,7 @@ qr/runtime error: rewrite_by_lua\(nginx\.conf:\d+\):14: bad request/
|
|||
|
||||
--- no_error_log
|
||||
[alert]
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -987,6 +987,7 @@ hello in thread
|
|||
after
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1072,6 +1073,7 @@ hello in thread
|
|||
after
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1120,6 +1120,7 @@ body: hello world)$
|
|||
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# vim:set ft= ts=4 sw=4 et fdm=marker:
|
||||
|
||||
use Test::Nginx::Socket::Lua;
|
||||
our $SkipReason;
|
||||
|
||||
BEGIN {
|
||||
if ($ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$SkipReason = "http3 does not support ngx.req.socket and lua_check_client_abort";
|
||||
} elsif ($ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
$SkipReason = "http2 does not support ngx.req.socket and lua_check_client_abort";
|
||||
}
|
||||
}
|
||||
|
||||
use Test::Nginx::Socket::Lua $SkipReason ? (skip_all => $SkipReason) : ();
|
||||
use t::StapThread;
|
||||
|
||||
our $GCScript = <<_EOC_;
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ GET /api?uid=32
|
|||
--- response_body
|
||||
Logged in 56
|
||||
--- timeout: 3
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -243,6 +244,7 @@ ngx.var.uid = res[1].uid;
|
|||
GET /api?uid=32
|
||||
--- response_body
|
||||
Logged in 56
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,6 +322,7 @@ ngx.var.uid = res[1].uid;
|
|||
GET /api?uid=32
|
||||
--- response_body
|
||||
Logged in 56
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ our $StapScript = $t::StapThread::StapScript;
|
|||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => repeat_each() * (blocks() * 4 + 15);
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
plan(skip_all => "HTTP3 does not support on_abort");
|
||||
} elsif (defined $ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
plan(skip_all => "HTTP2 does not support on_abort");
|
||||
} else {
|
||||
plan tests => repeat_each() * (blocks() * 4 + 15);
|
||||
}
|
||||
|
||||
$ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8';
|
||||
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= '11211';
|
||||
|
|
|
|||
|
|
@ -119,6 +119,15 @@ GET /read
|
|||
}
|
||||
--- request
|
||||
GET /read
|
||||
--- raw_response_headers_like: Location: /foo\r\n
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
$headers = "location: /foo\r\n"
|
||||
} else {
|
||||
$headers = "Location: /foo\r\n"
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body_like: 302 Found
|
||||
--- error_code: 302
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ Expect: 100-Continue
|
|||
[alert]
|
||||
[error]
|
||||
http finalize request: 500, "/test?" a:1, c:0
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -170,3 +170,26 @@ Expect: 100-Continue
|
|||
http finalize request: 500, "/echo_body?" a:1, c:2
|
||||
http finalize request: 500, "/echo_body?" a:1, c:0
|
||||
--- log_level: debug
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
=== TEST 9: test HTTP2 reading request body was disabled
|
||||
--- config
|
||||
location /echo_body {
|
||||
lua_need_request_body on;
|
||||
access_by_lua_block {
|
||||
ngx.print(ngx.var.request_body or "nil")
|
||||
}
|
||||
content_by_lua 'ngx.exit(ngx.OK)';
|
||||
}
|
||||
--- http2
|
||||
--- request eval
|
||||
"POST /echo_body
|
||||
hello\x00\x01\x02
|
||||
world\x03\x04\xff"
|
||||
--- more_headers
|
||||
Content-Length:
|
||||
--- response_body eval
|
||||
"nil"
|
||||
--- no_error_log
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ bad argument #1 to 'sleep'
|
|||
|
||||
|
||||
=== TEST 5: sleep 0.5 - multi-times
|
||||
--- quic_max_idle_timeout: 1.0
|
||||
--- config
|
||||
location /test {
|
||||
access_by_lua '
|
||||
|
|
@ -135,6 +136,7 @@ lua sleep timer expired: "/test?"
|
|||
|
||||
|
||||
=== TEST 6: sleep 0.5 - interleaved by ngx.say() - ended by ngx.sleep
|
||||
--- quic_max_idle_timeout: 2.2
|
||||
--- config
|
||||
location /test {
|
||||
access_by_lua '
|
||||
|
|
@ -163,6 +165,7 @@ lua sleep timer expired: "/test?"
|
|||
|
||||
|
||||
=== TEST 7: sleep 0.5 - interleaved by ngx.say() - not ended by ngx.sleep
|
||||
--- quic_max_idle_timeout: 0.85
|
||||
--- config
|
||||
location /test {
|
||||
access_by_lua '
|
||||
|
|
|
|||
|
|
@ -880,6 +880,7 @@ after
|
|||
|
||||
|
||||
=== TEST 11: exit in user thread (entry thread is still pending on reqsock:receive)
|
||||
--- skip_eval: 5:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- config
|
||||
location /lua {
|
||||
access_by_lua '
|
||||
|
|
@ -973,6 +974,7 @@ after
|
|||
|
||||
|
||||
=== TEST 12: exit in user thread (entry thread is still pending on ngx.req.read_body)
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- config
|
||||
location /lua {
|
||||
client_body_timeout 12000ms;
|
||||
|
|
|
|||
|
|
@ -1120,3 +1120,4 @@ body: hello world)$
|
|||
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
|
|
|||
|
|
@ -966,6 +966,7 @@ qr/\[alert\] \S+ lua_code_cache is off; this will hurt performance/,
|
|||
|
||||
|
||||
=== TEST 27: GC issue with the on_abort thread object
|
||||
curl: (52) Empty reply from server
|
||||
--- config
|
||||
lua_code_cache off;
|
||||
location = /t {
|
||||
|
|
@ -991,6 +992,8 @@ decrementing the reference count for Lua VM: 3
|
|||
qr/\[alert\] \S+ lua_code_cache is off; this will hurt performance/,
|
||||
"lua close the global Lua VM",
|
||||
]
|
||||
--- curl_error eval
|
||||
qr/curl: \(\d+\) Empty reply from server|curl: \(28\) Operation timed out after \d+ milliseconds with 0 bytes received/
|
||||
|
||||
|
||||
|
||||
|
|
@ -1720,6 +1723,7 @@ grep me: b
|
|||
}
|
||||
--- config
|
||||
lua_ssl_trusted_certificate $TEST_NGINX_CERT_DIR/cert/test.crt;
|
||||
lua_ssl_protocols TLSv1 TLSv1.1 TLSV1.2;
|
||||
|
||||
location = /proxy {
|
||||
proxy_pass http://backend;
|
||||
|
|
@ -1877,3 +1881,4 @@ qr/log_by_lua\(nginx.conf:\d+\):\d+: hello/,
|
|||
--- log_level: debug
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 14:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ kill status = 200
|
|||
kill body = \{"errcode":0\}$
|
||||
--- error_log eval
|
||||
qr{upstream timed out \(\d+: Connection timed out\) while sending query to drizzle upstream}
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,8 +59,13 @@ lua exceeding request header limit
|
|||
for k, v in pairs(headers) do
|
||||
h[k] = v
|
||||
end
|
||||
ngx.say("Foo: ", h["Foo"] or "nil")
|
||||
ngx.say("Bar: ", h["Bar"] or "nil")
|
||||
if (ngx.req.http_version() == 3 or ngx.req.http_version() == 2) then
|
||||
ngx.say("Foo: ", h["foo"] or "nil")
|
||||
ngx.say("Bar: ", h["bar"] or "nil")
|
||||
else
|
||||
ngx.say("Foo: ", h["Foo"] or "nil")
|
||||
ngx.say("Bar: ", h["Bar"] or "nil")
|
||||
end
|
||||
';
|
||||
}
|
||||
--- request
|
||||
|
|
@ -127,6 +132,8 @@ Foo:
|
|||
--- response_body eval
|
||||
"a" x 2048
|
||||
--- timeout: 15
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -145,6 +152,8 @@ Foo:
|
|||
--- response_body eval
|
||||
"a" x 2048
|
||||
--- timeout: 15
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -273,8 +282,13 @@ Content-Type:
|
|||
}
|
||||
--- request
|
||||
GET /bar
|
||||
--- response_body
|
||||
Foo: a
|
||||
--- response_body eval
|
||||
# Since nginx version 1.23.0, nginx combines same $http_* variable together
|
||||
$Test::Nginx::Util::NginxVersion >= 1.023000 ?
|
||||
|
||||
"Foo: a, b\n"
|
||||
:
|
||||
"Foo: a\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -480,6 +494,8 @@ for my $k (@k) {
|
|||
--- timeout: 4
|
||||
--- error_log
|
||||
lua exceeding request header limit 101 > 100
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -518,20 +534,30 @@ while ($i <= 98) {
|
|||
$s
|
||||
--- response_body eval
|
||||
my @k;
|
||||
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
push @k, "host: localhost\n";
|
||||
}
|
||||
my $i = 1;
|
||||
while ($i <= 98) {
|
||||
push @k, "x-$i";
|
||||
$i++;
|
||||
}
|
||||
push @k, "connection: close\n";
|
||||
push @k, "host: localhost\n";
|
||||
|
||||
my $found_headers = "found 99 headers\n";
|
||||
if (!defined($ENV{TEST_NGINX_USE_HTTP3}) && !defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
push @k, "connection: close\n";
|
||||
push @k, "host: localhost\n";
|
||||
$found_headers = "found 100 headers\n";
|
||||
}
|
||||
@k = sort @k;
|
||||
for my $k (@k) {
|
||||
if ($k =~ /\d+/) {
|
||||
$k .= ": $&\n";
|
||||
}
|
||||
}
|
||||
CORE::join("", @k) . "found 100 headers\n";
|
||||
|
||||
CORE::join("", @k) . $found_headers;
|
||||
--- timeout: 4
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
@ -571,6 +597,9 @@ while ($i <= 101) {
|
|||
$s
|
||||
--- response_body eval
|
||||
my @k;
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
push @k, "host: localhost\n";
|
||||
}
|
||||
my $i = 1;
|
||||
while ($i <= 100) {
|
||||
push @k, "x-$i";
|
||||
|
|
@ -588,6 +617,8 @@ for my $k (@k) {
|
|||
--- timeout: 4
|
||||
--- error_log
|
||||
lua exceeding request header limit 103 > 102
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -623,13 +654,20 @@ while ($i <= 100) {
|
|||
$s
|
||||
--- response_body eval
|
||||
my @k;
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
push @k, "host: localhost\n";
|
||||
}
|
||||
my $i = 1;
|
||||
while ($i <= 100) {
|
||||
push @k, "x-$i";
|
||||
$i++;
|
||||
}
|
||||
push @k, "connection: close\n";
|
||||
push @k, "host: localhost\n";
|
||||
|
||||
if (!defined($ENV{TEST_NGINX_USE_HTTP3}) && !defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
push @k, "connection: close\n";
|
||||
push @k, "host: localhost\n";
|
||||
}
|
||||
|
||||
@k = sort @k;
|
||||
for my $k (@k) {
|
||||
if ($k =~ /\d+/) {
|
||||
|
|
@ -676,13 +714,18 @@ while ($i <= 105) {
|
|||
$s
|
||||
--- response_body eval
|
||||
my @k;
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
push @k, "host: localhost\n";
|
||||
}
|
||||
my $i = 1;
|
||||
while ($i <= 105) {
|
||||
push @k, "x-$i";
|
||||
$i++;
|
||||
}
|
||||
push @k, "connection: close\n";
|
||||
push @k, "host: localhost\n";
|
||||
if (!defined($ENV{TEST_NGINX_USE_HTTP3}) && !defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
push @k, "connection: close\n";
|
||||
push @k, "host: localhost\n";
|
||||
}
|
||||
@k = sort @k;
|
||||
for my $k (@k) {
|
||||
if ($k =~ /\d+/) {
|
||||
|
|
@ -825,10 +868,21 @@ hello world
|
|||
Content-Type: application/ocsp-request
|
||||
Test-Header: 1
|
||||
--- response_body_like eval
|
||||
qr/Connection: close\r
|
||||
my $body;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$body = qr/Connection: close\r
|
||||
test-header: 1\r
|
||||
\r
|
||||
$/;
|
||||
} else {
|
||||
$body = qr/Connection: close\r
|
||||
Test-Header: 1\r
|
||||
\r
|
||||
$/
|
||||
$/;
|
||||
}
|
||||
|
||||
$body;
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -876,7 +930,36 @@ Foo20: foo20
|
|||
Foo21: foo21
|
||||
Foo22: foo22
|
||||
--- response_body_like eval
|
||||
qr/Bah: bah\r
|
||||
my $headers;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$headers = qr/bah: bah\r
|
||||
test-header: 1\r
|
||||
foo1: foo1\r
|
||||
foo2: foo2\r
|
||||
foo3: foo3\r
|
||||
foo4: foo4\r
|
||||
foo5: foo5\r
|
||||
foo6: foo6\r
|
||||
foo7: foo7\r
|
||||
foo8: foo8\r
|
||||
foo9: foo9\r
|
||||
foo10: foo10\r
|
||||
foo11: foo11\r
|
||||
foo12: foo12\r
|
||||
foo13: foo13\r
|
||||
foo14: foo14\r
|
||||
foo15: foo15\r
|
||||
foo16: foo16\r
|
||||
foo17: foo17\r
|
||||
foo18: foo18\r
|
||||
foo19: foo19\r
|
||||
foo20: foo20\r
|
||||
foo21: foo21\r
|
||||
foo22: foo22\r
|
||||
/;
|
||||
} else {
|
||||
$headers = qr/Bah: bah\r
|
||||
Test-Header: 1\r
|
||||
Foo1: foo1\r
|
||||
Foo2: foo2\r
|
||||
|
|
@ -900,7 +983,10 @@ Foo19: foo19\r
|
|||
Foo20: foo20\r
|
||||
Foo21: foo21\r
|
||||
Foo22: foo22\r
|
||||
/
|
||||
/;
|
||||
}
|
||||
|
||||
$headers;
|
||||
|
||||
|
||||
|
||||
|
|
@ -931,11 +1017,21 @@ GET /t
|
|||
--- more_headers
|
||||
My-Foo: bar
|
||||
Bar: baz
|
||||
--- response_body
|
||||
Bar: baz
|
||||
--- response_body eval
|
||||
my $body;
|
||||
if ($ENV{TEST_NGINX_USE_HTTP3} || $ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
$body = "bar: baz
|
||||
host: localhost
|
||||
my-foo: bar
|
||||
";
|
||||
} else {
|
||||
$body = "Bar: baz
|
||||
Connection: close
|
||||
Host: localhost
|
||||
My-Foo: bar
|
||||
";
|
||||
}
|
||||
$body;
|
||||
|
||||
|
||||
|
||||
|
|
@ -1005,29 +1101,23 @@ for my $i ('a' .. 'r') {
|
|||
}
|
||||
$s
|
||||
--- response_body eval
|
||||
"GET /back HTTP/1.0\r
|
||||
my $s = "GET /back HTTP/1.0\r
|
||||
Host: foo\r
|
||||
Connection: close\r
|
||||
User-Agent: curl\r
|
||||
A: a\r
|
||||
B: b\r
|
||||
C: c\r
|
||||
D: d\r
|
||||
E: e\r
|
||||
F: f\r
|
||||
G: g\r
|
||||
H: h\r
|
||||
I: i\r
|
||||
J: j\r
|
||||
K: k\r
|
||||
L: l\r
|
||||
M: m\r
|
||||
N: n\r
|
||||
O: o\r
|
||||
P: p\r
|
||||
Q: q\r
|
||||
\r
|
||||
"
|
||||
Connection: close\r\n";
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$s .= "user-agent: curl\r\n";
|
||||
for my $i ('a' .. 'q') {
|
||||
$s .= $i . ": " . "$i\r\n"
|
||||
}
|
||||
} else {
|
||||
$s .= "User-Agent: curl\r\n";
|
||||
for my $i ('a' .. 'q') {
|
||||
$s .= uc($i) . ": " . "$i\r\n"
|
||||
}
|
||||
}
|
||||
|
||||
$s . "\r\n";
|
||||
|
||||
|
||||
|
||||
|
|
@ -1058,7 +1148,55 @@ for my $i ('a' .. 'r') {
|
|||
}
|
||||
$s
|
||||
--- response_body eval
|
||||
"GET /back HTTP/1.0\r
|
||||
my $body;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$body = "GET /back HTTP/1.0\r
|
||||
Host: foo\r
|
||||
Connection: close\r
|
||||
user-agent: curl\r
|
||||
a: a\r
|
||||
b: b\r
|
||||
c: c\r
|
||||
d: d\r
|
||||
e: e\r
|
||||
f: f\r
|
||||
g: g\r
|
||||
h: h\r
|
||||
i: i\r
|
||||
j: j\r
|
||||
k: k\r
|
||||
l: l\r
|
||||
m: m\r
|
||||
n: n\r
|
||||
o: o\r
|
||||
p: p\r
|
||||
q: q\r
|
||||
foo-1: 1\r
|
||||
foo-2: 2\r
|
||||
foo-3: 3\r
|
||||
foo-4: 4\r
|
||||
foo-5: 5\r
|
||||
foo-6: 6\r
|
||||
foo-7: 7\r
|
||||
foo-8: 8\r
|
||||
foo-9: 9\r
|
||||
foo-10: 10\r
|
||||
foo-11: 11\r
|
||||
foo-12: 12\r
|
||||
foo-13: 13\r
|
||||
foo-14: 14\r
|
||||
foo-15: 15\r
|
||||
foo-16: 16\r
|
||||
foo-17: 17\r
|
||||
foo-18: 18\r
|
||||
foo-19: 19\r
|
||||
foo-20: 20\r
|
||||
foo-21: 21\r
|
||||
\r
|
||||
";
|
||||
} else {
|
||||
$body = "GET /back HTTP/1.0\r
|
||||
Host: foo\r
|
||||
Connection: close\r
|
||||
User-Agent: curl\r
|
||||
|
|
@ -1101,7 +1239,10 @@ foo-19: 19\r
|
|||
foo-20: 20\r
|
||||
foo-21: 21\r
|
||||
\r
|
||||
"
|
||||
";
|
||||
}
|
||||
|
||||
$body;
|
||||
|
||||
|
||||
|
||||
|
|
@ -1130,7 +1271,34 @@ for my $i ('a' .. 'r') {
|
|||
}
|
||||
$s
|
||||
--- response_body eval
|
||||
"GET /back HTTP/1.0\r
|
||||
my $body;
|
||||
|
||||
if ($ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$body = "GET /back HTTP/1.0\r
|
||||
Host: foo\r
|
||||
Connection: close\r
|
||||
user-agent: curl\r
|
||||
bah: bah\r
|
||||
a: a\r
|
||||
b: b\r
|
||||
c: c\r
|
||||
d: d\r
|
||||
e: e\r
|
||||
f: f\r
|
||||
g: g\r
|
||||
h: h\r
|
||||
i: i\r
|
||||
j: j\r
|
||||
k: k\r
|
||||
l: l\r
|
||||
m: m\r
|
||||
n: n\r
|
||||
o: o\r
|
||||
p: p\r
|
||||
\r
|
||||
"
|
||||
} else {
|
||||
$body = "GET /back HTTP/1.0\r
|
||||
Host: foo\r
|
||||
Connection: close\r
|
||||
User-Agent: curl\r
|
||||
|
|
@ -1153,6 +1321,9 @@ O: o\r
|
|||
P: p\r
|
||||
\r
|
||||
"
|
||||
}
|
||||
|
||||
$body;
|
||||
|
||||
|
||||
|
||||
|
|
@ -1184,7 +1355,55 @@ for my $i ('a' .. 'r') {
|
|||
}
|
||||
$s
|
||||
--- response_body eval
|
||||
"GET /back HTTP/1.0\r
|
||||
my $body;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$body = "GET /back HTTP/1.0\r
|
||||
Host: foo\r
|
||||
Connection: close\r
|
||||
user-agent: curl\r
|
||||
bah: bah\r
|
||||
a: a\r
|
||||
b: b\r
|
||||
c: c\r
|
||||
d: d\r
|
||||
e: e\r
|
||||
f: f\r
|
||||
g: g\r
|
||||
h: h\r
|
||||
i: i\r
|
||||
j: j\r
|
||||
k: k\r
|
||||
l: l\r
|
||||
m: m\r
|
||||
n: n\r
|
||||
o: o\r
|
||||
p: p\r
|
||||
foo-1: 1\r
|
||||
foo-2: 2\r
|
||||
foo-3: 3\r
|
||||
foo-4: 4\r
|
||||
foo-5: 5\r
|
||||
foo-6: 6\r
|
||||
foo-7: 7\r
|
||||
foo-8: 8\r
|
||||
foo-9: 9\r
|
||||
foo-10: 10\r
|
||||
foo-11: 11\r
|
||||
foo-12: 12\r
|
||||
foo-13: 13\r
|
||||
foo-14: 14\r
|
||||
foo-15: 15\r
|
||||
foo-16: 16\r
|
||||
foo-17: 17\r
|
||||
foo-18: 18\r
|
||||
foo-19: 19\r
|
||||
foo-20: 20\r
|
||||
foo-21: 21\r
|
||||
\r
|
||||
";
|
||||
} else {
|
||||
$body = "GET /back HTTP/1.0\r
|
||||
Host: foo\r
|
||||
Connection: close\r
|
||||
User-Agent: curl\r
|
||||
|
|
@ -1228,6 +1447,9 @@ foo-20: 20\r
|
|||
foo-21: 21\r
|
||||
\r
|
||||
"
|
||||
}
|
||||
|
||||
$body;
|
||||
|
||||
|
||||
|
||||
|
|
@ -1259,11 +1481,23 @@ GET /t
|
|||
--- more_headers
|
||||
My-Foo: bar
|
||||
Bar: baz
|
||||
--- response_body
|
||||
Bar: baz
|
||||
--- response_body eval
|
||||
my $body;
|
||||
|
||||
if (defined($ENV{TEST_NGINX_USE_HTTP3})|| defined($ENV{TEST_NGINX_USE_HTTP2})) {
|
||||
$body="bar: baz
|
||||
host: localhost
|
||||
my-foo: bar
|
||||
";
|
||||
} else {
|
||||
$body="Bar: baz
|
||||
Connection: close
|
||||
Host: localhost
|
||||
My-Foo: bar
|
||||
";
|
||||
}
|
||||
|
||||
$body;
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -1898,6 +2132,8 @@ found 3 headers.
|
|||
lua exceeding request header limit 4 > 3
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1934,6 +2170,8 @@ found 3 headers.
|
|||
--- no_error_log
|
||||
lua exceeding request header limit
|
||||
[error]
|
||||
--- skip_eval: 4: $ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -1972,6 +2210,8 @@ found 3 headers.
|
|||
lua exceeding request header limit 4 > 3
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 4: $ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- no_http2
|
||||
|
||||
|
||||
|
||||
|
|
@ -2002,12 +2242,22 @@ while ($i <= 1) {
|
|||
$i++;
|
||||
}
|
||||
$s
|
||||
--- response_body
|
||||
found 3 headers.
|
||||
--- response_body eval
|
||||
my $body;
|
||||
if (!defined $ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
$body = "found 3 headers.
|
||||
";
|
||||
} else {
|
||||
$body = "found 2 headers.
|
||||
";
|
||||
}
|
||||
|
||||
$body;
|
||||
--- timeout: 4
|
||||
--- no_error_log
|
||||
lua exceeding request header limit
|
||||
[error]
|
||||
--- skip_eval: 4: $ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ a=3&b=4&c
|
|||
--- request
|
||||
POST /lua
|
||||
--- response_body
|
||||
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -278,6 +278,8 @@ GET /t
|
|||
[error]
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -361,8 +361,11 @@ he
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -648,8 +651,12 @@ regex: (?:>[\w\s]*</?\w{2,}>)
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "([0-9]+"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile\(\) failed: missing closing parenthesis in \"\([0-9]+\"\n"
|
||||
:
|
||||
"error: pcre_compile\(\) failed: missing \) in \"\([0-9]+\"\n"
|
||||
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
@ -939,8 +946,11 @@ nil
|
|||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_body_like chop
|
||||
^error: pcre_exec\(\) failed: -10$
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre_exec\(\) failed: -4\n"
|
||||
:
|
||||
"error: pcre_exec\(\) failed: -10\n"
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
@ -1050,8 +1060,14 @@ end
|
|||
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_exec() failed: -8
|
||||
--- response_body eval
|
||||
# lua_regex_match_limit uses pcre_extra->match_limit in the PCRE,
|
||||
# but PCRE2 replaces this with pcre2_set_match_limit interface,
|
||||
# which has different effects.
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"failed to match\n"
|
||||
:
|
||||
"error: pcre_exec() failed: -8\n"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -698,8 +698,11 @@ not matched!
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -735,8 +738,11 @@ error: pcre_compile() failed: missing ) in "(abc"
|
|||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_body_like chop
|
||||
error: pcre_exec\(\) failed: -10
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre_exec\(\) failed: -4\n"
|
||||
:
|
||||
"error: pcre_exec\(\) failed: -10\n"
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
@ -854,8 +860,14 @@ end
|
|||
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_exec() failed: -8
|
||||
--- response_body eval
|
||||
# lua_regex_match_limit uses pcre_extra->match_limit in the PCRE,
|
||||
# but PCRE2 replaces this with pcre2_set_match_limit interface,
|
||||
# which has different effects.
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"failed to match\n"
|
||||
:
|
||||
"error: pcre_exec() failed: -8\n"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
24
t/036-sub.t
24
t/036-sub.t
|
|
@ -480,8 +480,11 @@ a [b c] [b] [c] [] [] d
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -506,8 +509,11 @@ error: pcre_compile() failed: missing ) in "(abc"
|
|||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_body_like chop
|
||||
error: pcre_exec\(\) failed: -10
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre_exec\(\) failed: -4\n"
|
||||
:
|
||||
"error: pcre_exec\(\) failed: -10\n"
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
@ -610,8 +616,14 @@ ngx.say("sub: ", cnt)
|
|||
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_exec() failed: -8
|
||||
--- response_body eval
|
||||
# lua_regex_match_limit uses pcre_extra->match_limit in the PCRE,
|
||||
# but PCRE2 replaces this with pcre2_set_match_limit interface,
|
||||
# which has different effects.
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"sub: 0\n"
|
||||
:
|
||||
"error: pcre_exec() failed: -8\n"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
17
t/037-gsub.t
17
t/037-gsub.t
|
|
@ -423,8 +423,11 @@ n: 1
|
|||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_body_like chop
|
||||
error: pcre_exec\(\) failed: -10
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre_exec\(\) failed: -4\n"
|
||||
:
|
||||
"error: pcre_exec\(\) failed: -10\n"
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
@ -531,8 +534,14 @@ ngx.say("gsub: ", cnt)
|
|||
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_exec() failed: -8
|
||||
--- response_body eval
|
||||
# lua_regex_match_limit uses pcre_extra->match_limit in the PCRE,
|
||||
# but PCRE2 replaces this with pcre2_set_match_limit interface,
|
||||
# which has different effects.
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"gsub: 0\n"
|
||||
:
|
||||
"error: pcre_exec() failed: -8\n"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -336,8 +336,11 @@ he
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ Hi
|
|||
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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -465,6 +467,8 @@ GET /lua
|
|||
failed to run header_filter_by_lua*: header_filter_by_lua(nginx.conf:47):2: Something bad
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -487,6 +491,8 @@ GET /lua
|
|||
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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -501,6 +507,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -515,6 +523,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -529,6 +539,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -543,6 +555,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -557,6 +571,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -575,6 +591,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -593,6 +611,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -607,6 +627,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -621,6 +643,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -635,6 +659,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -665,8 +691,10 @@ uri: /blah
|
|||
--- request
|
||||
GET /lua
|
||||
--- ignore_response
|
||||
--- error_log
|
||||
API disabled in the context of header_filter_by_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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -679,8 +707,18 @@ API disabled in the context of header_filter_by_lua*
|
|||
--- request
|
||||
GET /lua
|
||||
--- ignore_response
|
||||
--- error_log
|
||||
API disabled in the context of header_filter_by_lua*
|
||||
--- error_log eval
|
||||
my $err_log;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$err_log = "http v3 not supported yet";
|
||||
} else {
|
||||
$err_log = "API disabled in the context of header_filter_by_lua*";
|
||||
}
|
||||
|
||||
$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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -695,6 +733,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -709,6 +749,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -756,6 +798,8 @@ stack traceback:
|
|||
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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -774,6 +818,8 @@ GET /lua?a=1&b=2
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -820,6 +866,8 @@ GET /lua
|
|||
failed to load inlined Lua code: header_filter_by_lua(nginx.conf:41):2: unexpected symbol near ''for end''
|
||||
--- no_error_log
|
||||
no_such_error
|
||||
--- curl_error eval
|
||||
qr/curl: \(56\) Failure when receiving data from the peer/
|
||||
|
||||
|
||||
|
||||
|
|
@ -849,6 +897,8 @@ GET /lua
|
|||
failed to load inlined Lua code: header_filter_by_lua(nginx.conf:49):2: unexpected symbol near ''for end''
|
||||
--- no_error_log
|
||||
no_such_error
|
||||
--- curl_error eval
|
||||
qr/curl: \(56\) Failure when receiving data from the peer/
|
||||
|
||||
|
||||
|
||||
|
|
@ -873,3 +923,5 @@ GET /lua
|
|||
failed to load inlined Lua code: header_filter_by_lua(...901234567890123456789012345.conf:1):2: unexpected symbol near ''for end''
|
||||
--- no_error_log
|
||||
[alert]
|
||||
--- curl_error eval
|
||||
qr/curl: \(56\) Failure when receiving data from the peer/
|
||||
|
|
|
|||
|
|
@ -768,7 +768,7 @@ foo = 10502
|
|||
dogs:set("bar", 32, 0.001)
|
||||
dogs:set("baz", 32, 0.001)
|
||||
dogs:set("foo", 32, 0.001)
|
||||
ngx.location.capture("/sleep/0.002")
|
||||
ngx.location.capture("/sleep/0.003")
|
||||
local res, err, forcible = dogs:add("foo", 10502)
|
||||
ngx.say("add: ", res, " ", err, " ", forcible)
|
||||
ngx.say("foo = ", dogs:get("foo"))
|
||||
|
|
@ -797,7 +797,7 @@ foo = 10502
|
|||
dogs:set("bar", 32, 0.001)
|
||||
dogs:set("baz", 32, 0.001)
|
||||
dogs:set("foo", "hi", 0.001)
|
||||
ngx.location.capture("/sleep/0.002")
|
||||
ngx.location.capture("/sleep/0.003")
|
||||
local res, err, forcible = dogs:add("foo", "hello")
|
||||
ngx.say("add: ", res, " ", err, " ", forcible)
|
||||
ngx.say("foo = ", dogs:get("foo"))
|
||||
|
|
@ -1184,6 +1184,7 @@ nil nil
|
|||
|
||||
|
||||
=== TEST 45: flush_expires
|
||||
--- quic_max_idle_timeout: 1.6
|
||||
--- http_config
|
||||
lua_shared_dict dogs 1m;
|
||||
--- config
|
||||
|
|
@ -1210,6 +1211,7 @@ GET /t
|
|||
|
||||
|
||||
=== TEST 46: flush_expires with number
|
||||
--- quic_max_idle_timeout: 1.6
|
||||
--- http_config
|
||||
lua_shared_dict dogs 1m;
|
||||
--- config
|
||||
|
|
@ -1337,6 +1339,7 @@ GET /t
|
|||
|
||||
|
||||
=== TEST 51: list all keys in a shdict with expires
|
||||
--- quic_max_idle_timeout: 1.6
|
||||
--- http_config
|
||||
lua_shared_dict dogs 1m;
|
||||
--- config
|
||||
|
|
@ -1426,6 +1429,7 @@ GET /t
|
|||
|
||||
|
||||
=== TEST 55: list all keys in a shdict with all keys expired
|
||||
--- quic_max_idle_timeout: 1.6
|
||||
--- http_config
|
||||
lua_shared_dict dogs 1m;
|
||||
--- config
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ log_level('warn');
|
|||
|
||||
repeat_each(2);
|
||||
|
||||
plan tests => repeat_each() * (blocks() * 4 + 52 );
|
||||
plan tests => repeat_each() * (blocks() * 4 + 56);
|
||||
|
||||
#no_diff();
|
||||
no_long_string();
|
||||
|
|
@ -351,9 +351,18 @@ hello, world
|
|||
--- user_files
|
||||
>>> a.txt
|
||||
Will you change this world?
|
||||
--- raw_response_headers_like
|
||||
X-Old: \S+/client_body_temp/\d+\r
|
||||
.*?X-New: \S+/html/a\.txt\r
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$headers = qr#x-old: \S+/client_body_temp/\d+\r
|
||||
.*?x-new: \S+/html/a\.txt\r#;
|
||||
} else {
|
||||
$headers = qr#X-Old: \S+/client_body_temp/\d+\r
|
||||
.*?X-New: \S+/html/a\.txt\r#;
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body
|
||||
Will you change this world?
|
||||
--- no_error_log
|
||||
|
|
@ -390,9 +399,18 @@ hello, world!
|
|||
--- user_files
|
||||
>>> a.txt
|
||||
Will you change this world?
|
||||
--- raw_response_headers_like
|
||||
X-Old: \S+/client_body_temp/\d+\r
|
||||
.*?X-New: \S+/html/a\.txt\r
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$headers = qr#x-old: \S+/client_body_temp/\d+\r
|
||||
.*?x-new: \S+/html/a\.txt\r#;
|
||||
} else {
|
||||
$headers = qr#X-Old: \S+/client_body_temp/\d+\r
|
||||
.*?X-New: \S+/html/a\.txt\r#;
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body
|
||||
Will you change this world?
|
||||
--- no_error_log
|
||||
|
|
@ -898,6 +916,7 @@ body: hell
|
|||
--- no_error_log
|
||||
[error]
|
||||
[alert]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -959,6 +978,7 @@ body file: hello
|
|||
[alert]
|
||||
--- error_log
|
||||
a client request body is buffered to a temporary file
|
||||
--- skip_eval: 5:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -985,9 +1005,9 @@ a client request body is buffered to a temporary file
|
|||
--- error_code: 500
|
||||
--- error_log eval
|
||||
qr/lua entry thread aborted: runtime error: content_by_lua\(nginx\.conf:\d+\):2: request body not read yet/
|
||||
|
||||
--- no_error_log
|
||||
[alert]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1017,8 +1037,8 @@ body: hell
|
|||
--- no_error_log
|
||||
[error]
|
||||
[alert]
|
||||
--- no_error_log
|
||||
a client request body is buffered to a temporary file
|
||||
--- skip_eval: 5:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1241,8 +1261,8 @@ body: hello, my dear friend!
|
|||
--- no_error_log
|
||||
[error]
|
||||
[alert]
|
||||
--- no_error_log
|
||||
a client request body is buffered to a temporary file
|
||||
--- skip_eval: 5:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1382,8 +1402,8 @@ failed to get req socket: request body already exists
|
|||
--- no_error_log
|
||||
[error]
|
||||
[alert]
|
||||
--- no_error_log
|
||||
a client request body is buffered to a temporary file
|
||||
--- skip_eval: 5:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1405,6 +1425,7 @@ Expect: 100-Continue
|
|||
[alert]
|
||||
[error]
|
||||
http finalize request: 500, "/test?" a:1, c:0
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1480,13 +1501,22 @@ probe syscall.fcntl {
|
|||
--- stap_out_unlike
|
||||
fcntl\(O_DIRECT\)
|
||||
|
||||
--- raw_response_headers_like
|
||||
.*?X-New: \S+/html/a\.txt\r
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$headers = qr#.*?x-new: \S+/html/a\.txt\r#;
|
||||
} else {
|
||||
$headers = qr#.*?X-New: \S+/html/a\.txt\r#;
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body
|
||||
Will you change this world?
|
||||
--- no_error_log
|
||||
[error]
|
||||
[alert]
|
||||
--- skip_eval: 6:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1744,3 +1774,23 @@ content length: 5
|
|||
--- no_error_log
|
||||
[error]
|
||||
[alert]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
=== TEST 53: HTTP2 read buffered body was discarded
|
||||
--- config
|
||||
location = /test {
|
||||
content_by_lua_block {
|
||||
local err = pcall(ngx.req.read_body())
|
||||
ngx.say(err)
|
||||
}
|
||||
}
|
||||
--- http2
|
||||
--- request
|
||||
POST /test
|
||||
hello, world
|
||||
--- more_headers
|
||||
Content-Length:
|
||||
--- error_code: 500
|
||||
--- error_log: http2 requests are not supported without content-length header
|
||||
|
|
|
|||
|
|
@ -170,10 +170,22 @@ invalid referer: 1
|
|||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- raw_response_headers_like
|
||||
Proxy-Host: 127.0.0.1\:\d+\r
|
||||
--- raw_response_headers_like eval
|
||||
my $headers;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$headers =
|
||||
qr/proxy-host: 127.0.0.1\:\d+\r
|
||||
proxy-port: \d+\r
|
||||
proxy-add-x-forwarded-for: 127.0.0.1\r/;
|
||||
} else {
|
||||
$headers =
|
||||
qr/Proxy-Host: 127.0.0.1\:\d+\r
|
||||
Proxy-Port: \d+\r
|
||||
Proxy-Add-X-Forwarded-For: 127.0.0.1\r
|
||||
Proxy-Add-X-Forwarded-For: 127.0.0.1\r/;
|
||||
}
|
||||
|
||||
$headers;
|
||||
--- response_body
|
||||
hello
|
||||
--- no_error_log
|
||||
|
|
@ -248,19 +260,19 @@ variable "query_string" not changeable
|
|||
}
|
||||
server {
|
||||
# this is the real entry point
|
||||
listen 8091;
|
||||
listen $TEST_NGINX_RAND_PORT_1;
|
||||
location / {
|
||||
content_by_lua_block{
|
||||
ngx.print("this is backend peer 8091")
|
||||
ngx.print("this is backend peer $TEST_NGINX_RAND_PORT_1")
|
||||
}
|
||||
}
|
||||
}
|
||||
server {
|
||||
# this is the real entry point
|
||||
listen 8092;
|
||||
listen $TEST_NGINX_RAND_PORT_2;
|
||||
location / {
|
||||
content_by_lua_block{
|
||||
ngx.print("this is backend peer 8092")
|
||||
ngx.print("this is backend peer $TEST_NGINX_RAND_PORT_2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -275,6 +287,6 @@ variable "query_string" not changeable
|
|||
proxy_pass http://balancer;
|
||||
}
|
||||
--- pipelined_requests eval
|
||||
["GET /balancer?port=8091", "GET /balancer?port=8092"]
|
||||
["GET /balancer?port=\$TEST_NGINX_RAND_PORT_1", "GET /balancer?port=\$TEST_NGINX_RAND_PORT_2"]
|
||||
--- response_body eval
|
||||
["this is backend peer 8091", "this is backend peer 8092"]
|
||||
["this is backend peer \$TEST_NGINX_RAND_PORT_1", "this is backend peer \$TEST_NGINX_RAND_PORT_2"]
|
||||
|
|
|
|||
|
|
@ -32,8 +32,11 @@ __DATA__
|
|||
GET /re
|
||||
--- response_body
|
||||
1234
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -53,8 +56,11 @@ pcre JIT compiling result: 1
|
|||
GET /re
|
||||
--- response_body
|
||||
not matched!
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -76,9 +82,15 @@ pcre JIT compiling result: 1
|
|||
1234
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -101,9 +113,15 @@ qr/pcre JIT compiling result: \d+/
|
|||
not matched!
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -128,8 +146,11 @@ qr/pcre JIT compiling result: \d+/
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -170,8 +191,15 @@ end
|
|||
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_exec() failed: -8
|
||||
--- response_body eval
|
||||
# lua_regex_match_limit uses pcre_extra->match_limit in the PCRE,
|
||||
# but PCRE2 replaces this with pcre2_set_match_limit interface,
|
||||
# which has different effects.
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
# PCRE2_ERROR_MATCHLIMIT (-47)
|
||||
"error: pcre_exec() failed: -47\n"
|
||||
:
|
||||
"error: pcre_exec() failed: -8\n"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,8 +34,11 @@ __DATA__
|
|||
--- response_body
|
||||
hello
|
||||
world
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -60,8 +63,11 @@ pcre JIT compiling result: 1
|
|||
nil
|
||||
nil
|
||||
nil
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -77,8 +83,11 @@ pcre JIT compiling result: 1
|
|||
GET /re
|
||||
--- response_body
|
||||
done
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -99,8 +108,11 @@ pcre JIT compiling result: 1
|
|||
GET /re
|
||||
--- response_body
|
||||
hello
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -124,9 +136,15 @@ hello
|
|||
world
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -154,9 +172,15 @@ nil
|
|||
nil
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -175,9 +199,15 @@ qr/pcre JIT compiling result: \d+/
|
|||
done
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -201,9 +231,15 @@ qr/pcre JIT compiling result: \d+/
|
|||
hello
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -222,7 +258,10 @@ qr/pcre JIT compiling result: \d+/
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
|
|||
|
|
@ -214,8 +214,11 @@ hello
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,11 @@ __DATA__
|
|||
GET /re
|
||||
--- response_body
|
||||
hello, world 5678: 1
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -53,8 +56,11 @@ pcre JIT compiling result: 1
|
|||
GET /re
|
||||
--- response_body
|
||||
hello, world: 0
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -76,9 +82,15 @@ pcre JIT compiling result: 1
|
|||
hello, world 5678: 1
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -101,9 +113,15 @@ qr/pcre JIT compiling result: \d+/
|
|||
hello, world: 0
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -122,8 +140,11 @@ qr/pcre JIT compiling result: \d+/
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -143,7 +164,10 @@ error: pcre_compile() failed: missing ) in "(abc"
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
|
|||
|
|
@ -107,8 +107,11 @@ hello, world: 0
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -129,8 +132,11 @@ error: pcre_compile() failed: missing ) in "(abc"
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,11 @@ __DATA__
|
|||
GET /re
|
||||
--- response_body
|
||||
hello, world world: 2
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -53,8 +56,11 @@ pcre JIT compiling result: 1
|
|||
GET /re
|
||||
--- response_body
|
||||
hello, world: 0
|
||||
--- error_log
|
||||
pcre JIT compiling result: 1
|
||||
--- error_log eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully\n"
|
||||
:
|
||||
"pcre JIT compiling result: 1\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -76,9 +82,15 @@ pcre JIT compiling result: 1
|
|||
hello, world world: 2
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -101,9 +113,15 @@ qr/pcre JIT compiling result: \d+/
|
|||
hello, world: 0
|
||||
|
||||
--- grep_error_log eval
|
||||
qr/pcre JIT compiling result: \d+/
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"pcre2 JIT compiled successfully"
|
||||
:
|
||||
"pcre JIT compiling result: 1"
|
||||
|
||||
--- grep_error_log_out eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
["pcre2 JIT compiled successfully\n", ""]
|
||||
:
|
||||
["pcre JIT compiling result: 1\n", ""]
|
||||
|
||||
|
||||
|
|
@ -122,8 +140,11 @@ qr/pcre JIT compiling result: \d+/
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
@ -143,7 +164,10 @@ error: pcre_compile() failed: missing ) in "(abc"
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
|
|||
|
|
@ -107,8 +107,11 @@ hello, world: 0
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
|
||||
|
||||
|
||||
|
|
@ -126,8 +129,11 @@ error: pcre_compile() failed: missing ) in "(abc"
|
|||
}
|
||||
--- request
|
||||
GET /re
|
||||
--- response_body
|
||||
error: pcre_compile() failed: missing ) in "(abc"
|
||||
--- response_body eval
|
||||
$Test::Nginx::Util::PcreVersion == 2 ?
|
||||
"error: pcre2_compile() failed: missing closing parenthesis in \"(abc\"\n"
|
||||
:
|
||||
"error: pcre_compile() failed: missing ) in \"(abc\"\n"
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
|
|
|||
|
|
@ -491,6 +491,7 @@ GET /test
|
|||
|
||||
|
||||
=== TEST 17: limit_rate
|
||||
--- quic_max_idle_timeout: 2
|
||||
--- config
|
||||
location /test {
|
||||
limit_rate 150;
|
||||
|
|
@ -512,10 +513,19 @@ GET /test
|
|||
--- response_body eval
|
||||
"a" x 200
|
||||
--- error_log eval
|
||||
[
|
||||
my @errlog;
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
@errlog = [
|
||||
qr/lua writes elapsed 0\.[7-9]\d+ sec/,
|
||||
qr/lua flush requires waiting: buffered 0x[0-9a-f]+, delayed:1/,
|
||||
];
|
||||
} else {
|
||||
@errlog = [
|
||||
qr/lua writes elapsed [12](?:\.\d+)? sec/,
|
||||
qr/lua flush requires waiting: buffered 0x[0-9a-f]+, delayed:1/,
|
||||
]
|
||||
];
|
||||
}
|
||||
@errlog;
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
|
|
|||
|
|
@ -19,9 +19,14 @@ BEGIN {
|
|||
$ENV{TEST_NGINX_EVENT_TYPE} = 'poll';
|
||||
$ENV{MOCKEAGAIN_WRITE_TIMEOUT_PATTERN} = 'hello, world';
|
||||
$ENV{TEST_NGINX_POSTPONE_OUTPUT} = 1;
|
||||
delete($ENV{TEST_NGINX_USE_HTTP2});
|
||||
|
||||
if ($ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$SkipReason = "HTTP3 does not support mockeagain";
|
||||
}
|
||||
}
|
||||
|
||||
use Test::Nginx::Socket::Lua;
|
||||
use Test::Nginx::Socket::Lua $SkipReason ? (skip_all => $SkipReason) : ();
|
||||
use t::StapThread;
|
||||
|
||||
our $GCScript = $t::StapThread::GCScript;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ run_tests();
|
|||
__DATA__
|
||||
|
||||
=== TEST 1: sanity
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -90,6 +91,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 2: no trailing newline
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -253,10 +255,12 @@ second line received: (?:Date|Server): .*?
|
|||
--- no_error_log
|
||||
[error]
|
||||
--- timeout: 10
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
=== TEST 5: connection refused (tcp)
|
||||
--- no_http2
|
||||
--- config
|
||||
location /test {
|
||||
content_by_lua '
|
||||
|
|
@ -327,6 +331,7 @@ lua tcp socket connect timed out, when connecting to 127.0.0.2:12345
|
|||
|
||||
|
||||
=== TEST 7: not closed manually
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -441,6 +446,7 @@ attempt to send data on a closed socket
|
|||
|
||||
|
||||
=== TEST 10: explicit *l pattern for receive
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -509,6 +515,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 11: *a pattern for receive
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -577,6 +584,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 12: mixing *a and *l patterns for receive
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -656,6 +664,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 13: receive by chunks
|
||||
--- no_http2
|
||||
--- timeout: 5
|
||||
--- config
|
||||
server_tokens off;
|
||||
|
|
@ -731,6 +740,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 14: receive by chunks (very small buffer)
|
||||
--- no_http2
|
||||
--- timeout: 5
|
||||
--- config
|
||||
server_tokens off;
|
||||
|
|
@ -807,6 +817,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 15: line reading (very small buffer)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
lua_socket_buffer_size 1;
|
||||
|
|
@ -876,6 +887,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 16: ngx.socket.connect (working)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -982,6 +994,7 @@ qr/connect\(\) failed \(\d+: Connection refused\)/
|
|||
|
||||
|
||||
=== TEST 18: receive by chunks (stringified size)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1056,6 +1069,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 19: cannot survive across request boundary (send)
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -1115,6 +1129,7 @@ received: OK|failed to send request: closed)\$"
|
|||
|
||||
|
||||
=== TEST 20: cannot survive across request boundary (receive)
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -1190,6 +1205,7 @@ received: OK|failed to receive a line: closed \[nil\])$/
|
|||
|
||||
|
||||
=== TEST 21: cannot survive across request boundary (close)
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -1259,6 +1275,7 @@ received: OK|failed to close: closed)$/
|
|||
|
||||
|
||||
=== TEST 22: cannot survive across request boundary (connect)
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -1335,6 +1352,7 @@ lua reuse socket upstream ctx
|
|||
|
||||
|
||||
=== TEST 23: connect again immediately
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1403,6 +1421,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 24: two sockets mix together
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1494,6 +1513,7 @@ GET /t
|
|||
|
||||
|
||||
=== TEST 25: send tables of string fragments (with integers too)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1564,6 +1584,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 26: send tables of string fragments (bad type "nil")
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1619,10 +1640,13 @@ GET /t
|
|||
--- ignore_response
|
||||
--- error_log
|
||||
bad argument #1 to 'send' (bad data type nil found)
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
=== TEST 27: send tables of string fragments (bad type "boolean")
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1678,10 +1702,13 @@ GET /t
|
|||
--- ignore_response
|
||||
--- error_log
|
||||
bad argument #1 to 'send' (bad data type boolean found)
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
=== TEST 28: send tables of string fragments (bad type ngx.null)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1737,10 +1764,13 @@ GET /t
|
|||
--- ignore_response
|
||||
--- error_log
|
||||
bad argument #1 to 'send' (bad data type userdata found)
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
=== TEST 29: cosocket before location capture (tcpsock:send did not clear u->waiting)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1808,6 +1838,7 @@ subrequest: 200, OK\r
|
|||
|
||||
|
||||
=== TEST 30: CR in a line
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1877,6 +1908,7 @@ close: nil closed
|
|||
|
||||
|
||||
=== TEST 31: receive(0)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1935,6 +1967,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 32: send("")
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -2176,6 +2209,7 @@ lua tcp socket read timed out
|
|||
|
||||
|
||||
=== TEST 37: successful reread after a read time out happen (receive -> receive)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
resolver $TEST_NGINX_RESOLVER ipv6=off;
|
||||
|
|
@ -2253,6 +2287,7 @@ lua tcp socket read timed out
|
|||
|
||||
|
||||
=== TEST 38: successful reread after a read time out happen (receive -> receiveuntil)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
resolver $TEST_NGINX_RESOLVER ipv6=off;
|
||||
|
|
@ -2333,6 +2368,7 @@ lua tcp socket read timed out
|
|||
|
||||
|
||||
=== TEST 39: successful reread after a read time out happen (receiveuntil -> receiveuntil)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
resolver $TEST_NGINX_RESOLVER ipv6=off;
|
||||
|
|
@ -2415,6 +2451,7 @@ lua tcp socket read timed out
|
|||
|
||||
|
||||
=== TEST 40: successful reread after a read time out happen (receiveuntil -> receive)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
resolver $TEST_NGINX_RESOLVER ipv6=off;
|
||||
|
|
@ -2495,6 +2532,7 @@ lua tcp socket read timed out
|
|||
|
||||
|
||||
=== TEST 41: receive(0)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -2542,6 +2580,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 42: empty options table
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -2580,6 +2619,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 43: u->coctx left over bug
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location = /t {
|
||||
|
|
@ -2671,6 +2711,7 @@ lua clean up the timer for pending ngx.sleep
|
|||
|
||||
|
||||
=== TEST 44: bad request tries to connect
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -2725,6 +2766,7 @@ qr/runtime error: content_by_lua\(nginx\.conf:\d+\):7: bad request/
|
|||
|
||||
|
||||
=== TEST 45: bad request tries to receive
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -2782,6 +2824,7 @@ qr/runtime error: content_by_lua\(nginx\.conf:\d+\):14: bad request/
|
|||
|
||||
|
||||
=== TEST 46: bad request tries to send
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -2839,6 +2882,7 @@ qr/runtime error: content_by_lua\(nginx\.conf:\d+\):14: bad request/
|
|||
|
||||
|
||||
=== TEST 47: bad request tries to close
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -2896,6 +2940,7 @@ qr/runtime error: content_by_lua\(nginx\.conf:\d+\):14: bad request/
|
|||
|
||||
|
||||
=== TEST 48: bad request tries to set keepalive
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -2953,6 +2998,7 @@ qr/runtime error: content_by_lua\(nginx\.conf:\d+\):14: bad request/
|
|||
|
||||
|
||||
=== TEST 49: bad request tries to receiveuntil
|
||||
--- no_http2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -3084,6 +3130,7 @@ could not cancel
|
|||
|
||||
|
||||
=== TEST 52: tcp_nodelay on
|
||||
--- no_http2
|
||||
--- config
|
||||
tcp_nodelay on;
|
||||
server_tokens off;
|
||||
|
|
@ -3157,6 +3204,7 @@ lua socket tcp_nodelay
|
|||
|
||||
|
||||
=== TEST 53: tcp_nodelay off
|
||||
--- no_http2
|
||||
--- config
|
||||
tcp_nodelay off;
|
||||
server_tokens off;
|
||||
|
|
@ -3348,6 +3396,7 @@ lua tcp socket connect timeout: 100
|
|||
|
||||
|
||||
=== TEST 56: reuse cleanup
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -3412,6 +3461,7 @@ lua http cleanup reuse
|
|||
|
||||
|
||||
=== TEST 57: reuse cleanup in ngx.timer (fake_request)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -3495,6 +3545,7 @@ lua http cleanup reuse
|
|||
|
||||
|
||||
=== TEST 58: free cleanup in ngx.timer (without sock:close)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -3576,6 +3627,7 @@ total_send_bytes: 114
|
|||
|
||||
|
||||
=== TEST 59: reuse cleanup in subrequest
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -3644,6 +3696,7 @@ lua http cleanup reuse
|
|||
|
||||
|
||||
=== TEST 60: setkeepalive on socket already shutdown
|
||||
--- no_http2
|
||||
--- config
|
||||
location /t {
|
||||
set $port $TEST_NGINX_MEMCACHED_PORT;
|
||||
|
|
@ -3682,6 +3735,7 @@ failed to setkeepalive: closed
|
|||
|
||||
|
||||
=== TEST 61: options_table is nil
|
||||
--- no_http2
|
||||
--- config
|
||||
location /t {
|
||||
set $port $TEST_NGINX_MEMCACHED_PORT;
|
||||
|
|
@ -3788,6 +3842,7 @@ failed to connect: bad port number: 65536
|
|||
|
||||
|
||||
=== TEST 64: send boolean and nil
|
||||
--- no_http2
|
||||
--- config
|
||||
location /t {
|
||||
set $port $TEST_NGINX_SERVER_PORT;
|
||||
|
|
@ -3850,6 +3905,7 @@ received: truefalsenil
|
|||
|
||||
|
||||
=== TEST 65: receiveany method in cosocket
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location = /t {
|
||||
|
|
@ -3942,10 +3998,13 @@ lua tcp socket read any
|
|||
--- config
|
||||
server_tokens off;
|
||||
location = /t {
|
||||
set $port $TEST_NGINX_RAND_PORT_1;
|
||||
|
||||
content_by_lua_block {
|
||||
local sock = ngx.socket.tcp()
|
||||
local port = ngx.var.port
|
||||
sock:settimeout(500)
|
||||
assert(sock:connect("127.0.0.1", 7658))
|
||||
assert(sock:connect("127.0.0.1", port))
|
||||
|
||||
while true do
|
||||
local data, err = sock:receiveany(1024)
|
||||
|
|
@ -3972,7 +4031,7 @@ lua tcp socket read any
|
|||
|
||||
--- request
|
||||
GET /t
|
||||
--- tcp_listen: 7658
|
||||
--- tcp_listen: $TEST_NGINX_RAND_PORT_1
|
||||
--- tcp_shutdown: 1
|
||||
--- tcp_query eval: "send data after read side closed"
|
||||
--- tcp_query_len: 32
|
||||
|
|
@ -3983,6 +4042,7 @@ GET /t
|
|||
|
||||
|
||||
=== TEST 67: receiveany with limited, max <= 0
|
||||
--- no_http2
|
||||
--- config
|
||||
location = /t {
|
||||
set $port $TEST_NGINX_SERVER_PORT;
|
||||
|
|
@ -4019,6 +4079,7 @@ GET /t
|
|||
|
||||
|
||||
=== TEST 68: receiveany with limited, max is larger than data
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location = /t {
|
||||
|
|
@ -4088,6 +4149,7 @@ lua tcp socket calling receiveany() method to read at most 128 bytes
|
|||
|
||||
|
||||
=== TEST 69: receiveany with limited, max is smaller than data
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location = /t {
|
||||
|
|
@ -4162,6 +4224,7 @@ lua tcp socket calling receiveany() method to read at most 7 bytes
|
|||
|
||||
|
||||
=== TEST 70: send tables of string fragments (with floating point number too)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -4236,6 +4299,7 @@ close: 1 nil
|
|||
|
||||
=== TEST 71: send numbers
|
||||
the maximum number of significant digits is 14 in lua
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
|
|||
|
|
@ -262,6 +262,7 @@ hello world
|
|||
n = 6
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3: $ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -515,6 +516,7 @@ GET /test
|
|||
n = 7
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -554,6 +556,7 @@ narr = 2
|
|||
nrec = 3
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -589,3 +592,4 @@ narr = 2
|
|||
nrec = 3
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3: $ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ BEGIN {
|
|||
$ENV{MOCKEAGAIN} = 'w';
|
||||
}
|
||||
|
||||
delete($ENV{TEST_NGINX_USE_HTTP2});
|
||||
$ENV{TEST_NGINX_EVENT_TYPE} = 'poll';
|
||||
$ENV{MOCKEAGAIN_WRITE_TIMEOUT_PATTERN} = 'get helloworld';
|
||||
}
|
||||
|
|
@ -873,6 +874,7 @@ quitting request now
|
|||
--- no_error_log
|
||||
lua tcp socket write timed out
|
||||
[alert]
|
||||
--- skip_eval: 4: $ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 2: http read lines
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -140,6 +141,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 3: http read all the headers in a single run
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -208,6 +210,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 4: ambiguous boundary patterns (abcabd)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -279,6 +282,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 5: ambiguous boundary patterns (aa)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -350,6 +354,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 6: ambiguous boundary patterns (aaa)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -421,6 +426,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 7: ambiguous boundary patterns (aaaaad)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -492,6 +498,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 8: ambiguous boundary patterns (aaaaad), small buffer, 2 bytes
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
lua_socket_buffer_size 2;
|
||||
|
|
@ -564,6 +571,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 9: ambiguous boundary patterns (aaaaad), small buffer, 1 byte
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
lua_socket_buffer_size 1;
|
||||
|
|
@ -636,6 +644,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 10: ambiguous boundary patterns (abcabdabcabe)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -707,6 +716,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 11: ambiguous boundary patterns (abcabdabcabe 2)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -778,6 +788,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 12: ambiguous boundary patterns (abcabdabcabe 3)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -849,6 +860,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 13: ambiguous boundary patterns (abcabdabcabe 4)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -920,6 +932,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 14: ambiguous boundary patterns (--abc)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -991,6 +1004,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 15: ambiguous boundary patterns (--abc)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1066,6 +1080,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 16: ambiguous boundary patterns (--abc), small buffer
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1142,6 +1157,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 17: ambiguous boundary patterns (--abc), small buffer, mixed by other reading calls
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1230,6 +1246,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 18: ambiguous boundary patterns (abcabd), small buffer
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
lua_socket_buffer_size 3;
|
||||
|
|
@ -1327,6 +1344,7 @@ this exposed a memory leak in receiveuntil
|
|||
ok
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1402,3 +1420,595 @@ close: 1 nil
|
|||
}
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 21: ambiguous boundary patterns (--abc), mixed by other reading calls consume boundary
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
set $port $TEST_NGINX_SERVER_PORT;
|
||||
|
||||
content_by_lua_block {
|
||||
-- collectgarbage("collect")
|
||||
|
||||
local sock = ngx.socket.tcp()
|
||||
local port = ngx.var.port
|
||||
|
||||
local ok, err = sock:connect("127.0.0.1", port)
|
||||
if not ok then
|
||||
ngx.say("failed to connect: ", err)
|
||||
return
|
||||
end
|
||||
|
||||
ngx.say("connected: ", ok)
|
||||
|
||||
local req = "GET /foo HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n"
|
||||
|
||||
local bytes, err = sock:send(req)
|
||||
if not bytes then
|
||||
ngx.say("failed to send request: ", err)
|
||||
return
|
||||
end
|
||||
ngx.say("request sent: ", bytes)
|
||||
|
||||
local read_headers = sock:receiveuntil("\r\n\r\n")
|
||||
local headers, err, part = read_headers()
|
||||
if not headers then
|
||||
ngx.say("failed to read headers: ", err, " [", part, "]")
|
||||
end
|
||||
|
||||
local reader = sock:receiveuntil("--abc")
|
||||
|
||||
for i = 1, 5 do
|
||||
local line, err, part = reader(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
break
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local data, err, part = sock:receive(1)
|
||||
if not data then
|
||||
ngx.say("failed to read a byte: ", err, " [", part, "]")
|
||||
break
|
||||
|
||||
else
|
||||
ngx.say("read one byte: ", data)
|
||||
end
|
||||
end
|
||||
|
||||
local line, err, part = reader(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
ok, err = sock:close()
|
||||
ngx.say("close: ", ok, " ", err)
|
||||
}
|
||||
}
|
||||
|
||||
location /foo {
|
||||
echo -- ----abc----abc-;
|
||||
more_clear_headers Date;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- response_body eval
|
||||
qq{connected: 1
|
||||
request sent: 57
|
||||
read: --
|
||||
read one byte: -
|
||||
read: -a
|
||||
read one byte: b
|
||||
read: c-
|
||||
read one byte: -
|
||||
read:
|
||||
read one byte: -
|
||||
failed to read a line: nil [nil]
|
||||
failed to read a line: closed [
|
||||
]
|
||||
close: 1 nil
|
||||
}
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 22: ambiguous boundary patterns (--abc), mixed by other reading calls (including receiveuntil) consume boundary
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
set $port $TEST_NGINX_SERVER_PORT;
|
||||
|
||||
content_by_lua_block {
|
||||
-- collectgarbage("collect")
|
||||
|
||||
local sock = ngx.socket.tcp()
|
||||
local port = ngx.var.port
|
||||
|
||||
local ok, err = sock:connect("127.0.0.1", port)
|
||||
if not ok then
|
||||
ngx.say("failed to connect: ", err)
|
||||
return
|
||||
end
|
||||
|
||||
ngx.say("connected: ", ok)
|
||||
|
||||
local req = "GET /foo HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n"
|
||||
|
||||
local bytes, err = sock:send(req)
|
||||
if not bytes then
|
||||
ngx.say("failed to send request: ", err)
|
||||
return
|
||||
end
|
||||
ngx.say("request sent: ", bytes)
|
||||
|
||||
local read_headers = sock:receiveuntil("\r\n\r\n")
|
||||
local headers, err, part = read_headers()
|
||||
if not headers then
|
||||
ngx.say("failed to read headers: ", err, " [", part, "]")
|
||||
end
|
||||
|
||||
local reader1 = sock:receiveuntil("--abc")
|
||||
local reader2 = sock:receiveuntil("-ab")
|
||||
|
||||
local line, err, part = reader1(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local data, err, part = sock:receive(1)
|
||||
if not data then
|
||||
ngx.say("failed to read a byte: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read one byte: ", data)
|
||||
end
|
||||
|
||||
local line, err, part = reader1(1)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local line, err, part = reader2(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local line, err, part = reader1()
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local line, err, part = reader1()
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
ok, err = sock:close()
|
||||
ngx.say("close: ", ok, " ", err)
|
||||
}
|
||||
}
|
||||
|
||||
location /foo {
|
||||
echo -- ------abd----abc;
|
||||
more_clear_headers Date;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- response_body eval
|
||||
qq{connected: 1
|
||||
request sent: 57
|
||||
read: --
|
||||
read one byte: -
|
||||
read: -
|
||||
read: -
|
||||
read: d--
|
||||
failed to read a line: closed [
|
||||
]
|
||||
close: 1 nil
|
||||
}
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 23: ambiguous boundary patterns (--abc), mixed by other reading calls consume boundary, small buffer
|
||||
--- config
|
||||
lua_socket_buffer_size 3;
|
||||
server_tokens off;
|
||||
location /t {
|
||||
set $port $TEST_NGINX_SERVER_PORT;
|
||||
|
||||
content_by_lua_block {
|
||||
-- collectgarbage("collect")
|
||||
|
||||
local sock = ngx.socket.tcp()
|
||||
local port = ngx.var.port
|
||||
|
||||
local ok, err = sock:connect("127.0.0.1", port)
|
||||
if not ok then
|
||||
ngx.say("failed to connect: ", err)
|
||||
return
|
||||
end
|
||||
|
||||
ngx.say("connected: ", ok)
|
||||
|
||||
local req = "GET /foo HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n"
|
||||
|
||||
local bytes, err = sock:send(req)
|
||||
if not bytes then
|
||||
ngx.say("failed to send request: ", err)
|
||||
return
|
||||
end
|
||||
ngx.say("request sent: ", bytes)
|
||||
|
||||
local read_headers = sock:receiveuntil("\r\n\r\n")
|
||||
local headers, err, part = read_headers()
|
||||
if not headers then
|
||||
ngx.say("failed to read headers: ", err, " [", part, "]")
|
||||
end
|
||||
|
||||
local reader = sock:receiveuntil("--abc")
|
||||
|
||||
for i = 1, 5 do
|
||||
local line, err, part = reader(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
break
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local data, err, part = sock:receive(1)
|
||||
if not data then
|
||||
ngx.say("failed to read a byte: ", err, " [", part, "]")
|
||||
break
|
||||
|
||||
else
|
||||
ngx.say("read one byte: ", data)
|
||||
end
|
||||
end
|
||||
|
||||
local line, err, part = reader(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
ok, err = sock:close()
|
||||
ngx.say("close: ", ok, " ", err)
|
||||
}
|
||||
}
|
||||
|
||||
location /foo {
|
||||
echo -- ----abc----abc-;
|
||||
more_clear_headers Date;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- response_body eval
|
||||
qq{connected: 1
|
||||
request sent: 57
|
||||
read: --
|
||||
read one byte: -
|
||||
read: -a
|
||||
read one byte: b
|
||||
read: c-
|
||||
read one byte: -
|
||||
read:
|
||||
read one byte: -
|
||||
failed to read a line: nil [nil]
|
||||
failed to read a line: closed [
|
||||
]
|
||||
close: 1 nil
|
||||
}
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 24: ambiguous boundary patterns (--abc), mixed by other reading calls (including receiveuntil) consume boundary, small buffer
|
||||
--- config
|
||||
lua_socket_buffer_size 3;
|
||||
server_tokens off;
|
||||
location /t {
|
||||
set $port $TEST_NGINX_SERVER_PORT;
|
||||
|
||||
content_by_lua_block {
|
||||
-- collectgarbage("collect")
|
||||
|
||||
local sock = ngx.socket.tcp()
|
||||
local port = ngx.var.port
|
||||
|
||||
local ok, err = sock:connect("127.0.0.1", port)
|
||||
if not ok then
|
||||
ngx.say("failed to connect: ", err)
|
||||
return
|
||||
end
|
||||
|
||||
ngx.say("connected: ", ok)
|
||||
|
||||
local req = "GET /foo HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n"
|
||||
|
||||
local bytes, err = sock:send(req)
|
||||
if not bytes then
|
||||
ngx.say("failed to send request: ", err)
|
||||
return
|
||||
end
|
||||
ngx.say("request sent: ", bytes)
|
||||
|
||||
local read_headers = sock:receiveuntil("\r\n\r\n")
|
||||
local headers, err, part = read_headers()
|
||||
if not headers then
|
||||
ngx.say("failed to read headers: ", err, " [", part, "]")
|
||||
end
|
||||
|
||||
local reader1 = sock:receiveuntil("--abc")
|
||||
local reader2 = sock:receiveuntil("-ab")
|
||||
|
||||
local line, err, part = reader1(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local data, err, part = sock:receive(1)
|
||||
if not data then
|
||||
ngx.say("failed to read a byte: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read one byte: ", data)
|
||||
end
|
||||
|
||||
local line, err, part = reader1(1)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local line, err, part = reader2(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local line, err, part = reader1()
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
local line, err, part = reader1()
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
|
||||
ok, err = sock:close()
|
||||
ngx.say("close: ", ok, " ", err)
|
||||
}
|
||||
}
|
||||
|
||||
location /foo {
|
||||
echo -- ------abd----abc;
|
||||
more_clear_headers Date;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- response_body eval
|
||||
qq{connected: 1
|
||||
request sent: 57
|
||||
read: --
|
||||
read one byte: -
|
||||
read: -
|
||||
read: -
|
||||
read: d--
|
||||
failed to read a line: closed [
|
||||
]
|
||||
close: 1 nil
|
||||
}
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 25: ambiguous boundary patterns (ab1ab2), ends half way
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
set $port $TEST_NGINX_SERVER_PORT;
|
||||
|
||||
content_by_lua_block {
|
||||
-- collectgarbage("collect")
|
||||
|
||||
local sock = ngx.socket.tcp()
|
||||
local port = ngx.var.port
|
||||
|
||||
local ok, err = sock:connect("127.0.0.1", port)
|
||||
if not ok then
|
||||
ngx.say("failed to connect: ", err)
|
||||
return
|
||||
end
|
||||
|
||||
ngx.say("connected: ", ok)
|
||||
|
||||
local req = "GET /foo HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n"
|
||||
|
||||
local bytes, err = sock:send(req)
|
||||
if not bytes then
|
||||
ngx.say("failed to send request: ", err)
|
||||
return
|
||||
end
|
||||
ngx.say("request sent: ", bytes)
|
||||
|
||||
local read_headers = sock:receiveuntil("\r\n\r\n")
|
||||
local headers, err, part = read_headers()
|
||||
if not headers then
|
||||
ngx.say("failed to read headers: ", err, " [", part, "]")
|
||||
end
|
||||
|
||||
if true then
|
||||
local reader = sock:receiveuntil("ab1ab2")
|
||||
|
||||
local line, err, part = reader(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
end
|
||||
|
||||
collectgarbage("collect")
|
||||
|
||||
local data, err, part = sock:receive(3)
|
||||
if not data then
|
||||
ngx.say("failed to read three bytes: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read three bytes: ", data)
|
||||
end
|
||||
|
||||
ok, err = sock:close()
|
||||
ngx.say("close: ", ok, " ", err)
|
||||
}
|
||||
}
|
||||
|
||||
location /foo {
|
||||
echo -- ab1ab1;
|
||||
more_clear_headers Date;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- response_body eval
|
||||
qq{connected: 1
|
||||
request sent: 57
|
||||
read: ab1
|
||||
read three bytes: ab1
|
||||
close: 1 nil
|
||||
}
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 26: ambiguous boundary patterns (ab1ab2), ends half way, small buffer
|
||||
--- config
|
||||
lua_socket_buffer_size 3;
|
||||
server_tokens off;
|
||||
location /t {
|
||||
set $port $TEST_NGINX_SERVER_PORT;
|
||||
|
||||
content_by_lua_block {
|
||||
-- collectgarbage("collect")
|
||||
|
||||
local sock = ngx.socket.tcp()
|
||||
local port = ngx.var.port
|
||||
|
||||
local ok, err = sock:connect("127.0.0.1", port)
|
||||
if not ok then
|
||||
ngx.say("failed to connect: ", err)
|
||||
return
|
||||
end
|
||||
|
||||
ngx.say("connected: ", ok)
|
||||
|
||||
local req = "GET /foo HTTP/1.0\r\nHost: localhost\r\nConnection: close\r\n\r\n"
|
||||
|
||||
local bytes, err = sock:send(req)
|
||||
if not bytes then
|
||||
ngx.say("failed to send request: ", err)
|
||||
return
|
||||
end
|
||||
ngx.say("request sent: ", bytes)
|
||||
|
||||
local read_headers = sock:receiveuntil("\r\n\r\n")
|
||||
local headers, err, part = read_headers()
|
||||
if not headers then
|
||||
ngx.say("failed to read headers: ", err, " [", part, "]")
|
||||
end
|
||||
|
||||
if true then
|
||||
local reader = sock:receiveuntil("ab1ab2")
|
||||
|
||||
local line, err, part = reader(2)
|
||||
if not line then
|
||||
ngx.say("failed to read a line: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read: ", line)
|
||||
end
|
||||
end
|
||||
|
||||
collectgarbage("collect")
|
||||
|
||||
local data, err, part = sock:receive(3)
|
||||
if not data then
|
||||
ngx.say("failed to read three bytes: ", err, " [", part, "]")
|
||||
|
||||
else
|
||||
ngx.say("read three bytes: ", data)
|
||||
end
|
||||
|
||||
ok, err = sock:close()
|
||||
ngx.say("close: ", ok, " ", err)
|
||||
}
|
||||
}
|
||||
|
||||
location /foo {
|
||||
echo -- ab1ab1;
|
||||
more_clear_headers Date;
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
|
||||
--- response_body eval
|
||||
qq{connected: 1
|
||||
request sent: 57
|
||||
read: ab1
|
||||
read three bytes: ab1
|
||||
close: 1 nil
|
||||
}
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,16 @@
|
|||
# vim:set ft= ts=4 sw=4 et fdm=marker:
|
||||
|
||||
use Test::Nginx::Socket::Lua;
|
||||
our $SkipReason;
|
||||
|
||||
BEGIN {
|
||||
if ($ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$SkipReason = "http3 does not support ngx.req.socket";
|
||||
} elsif ($ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
$SkipReason = "http2 does not support ngx.req.socket";
|
||||
}
|
||||
}
|
||||
|
||||
use Test::Nginx::Socket::Lua $SkipReason ? (skip_all => $SkipReason) : ();
|
||||
|
||||
repeat_each(2);
|
||||
|
||||
|
|
|
|||
|
|
@ -168,6 +168,7 @@ received: OK
|
|||
|
||||
|
||||
=== TEST 3: upstream sockets close prematurely
|
||||
--- no_http3
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -243,6 +244,7 @@ done
|
|||
|
||||
|
||||
=== TEST 4: http keepalive
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- http_config eval
|
||||
"lua_package_path '$::HtmlDir/?.lua;./?.lua;;';"
|
||||
--- config
|
||||
|
|
@ -318,6 +320,7 @@ done
|
|||
|
||||
|
||||
=== TEST 5: lua_socket_keepalive_timeout
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -395,6 +398,7 @@ qr/lua tcp socket connection pool size: 30\b/]
|
|||
|
||||
|
||||
=== TEST 6: lua_socket_pool_size
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -473,6 +477,7 @@ qr/lua tcp socket connection pool size: 1\b/]
|
|||
|
||||
|
||||
=== TEST 7: "lua_socket_keepalive_timeout 0" means unlimited
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -548,6 +553,7 @@ qr/lua tcp socket connection pool size: 30\b/]
|
|||
|
||||
|
||||
=== TEST 8: setkeepalive(timeout) overrides lua_socket_keepalive_timeout
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -625,6 +631,7 @@ qr/lua tcp socket connection pool size: 30\b/]
|
|||
|
||||
|
||||
=== TEST 9: sock:setkeepalive(timeout, size) overrides lua_socket_pool_size
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -731,6 +738,7 @@ bad argument #3 to '?' (bad "pool_size" option value: 0)
|
|||
|
||||
|
||||
=== TEST 11: sock:keepalive_timeout(0) means unlimited
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1508,6 +1516,7 @@ done
|
|||
|
||||
|
||||
=== TEST 25: setkeepalive() with explicit nil args
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -1919,6 +1928,7 @@ too many waiting connect operations
|
|||
|
||||
|
||||
=== TEST 32: conn queuing: once 'pool_size' is reached and pool has 'backlog'
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
location /t {
|
||||
set $port $TEST_NGINX_MEMCACHED_PORT;
|
||||
|
|
@ -2536,6 +2546,8 @@ GET /t
|
|||
--- abort
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- curl_error eval
|
||||
qr/curl: \(28\) Operation timed out after \d+ milliseconds with 0 bytes received/
|
||||
|
||||
|
||||
|
||||
|
|
@ -2643,6 +2655,7 @@ lua tcp socket connect timed out, when connecting to
|
|||
|
||||
|
||||
=== TEST 46: conn queuing: resume connect operation if resumed connect failed (could not be resolved)
|
||||
--- quic_max_idle_timeout: 1.2
|
||||
--- config
|
||||
resolver 127.0.0.2:12345 ipv6=off;
|
||||
resolver_timeout 1s;
|
||||
|
|
|
|||
|
|
@ -444,6 +444,7 @@ GET /lua
|
|||
ok
|
||||
--- error_log
|
||||
API disabled in the context of log_by_lua*
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -457,8 +458,16 @@ API disabled in the context of log_by_lua*
|
|||
GET /lua
|
||||
--- response_body
|
||||
ok
|
||||
--- error_log
|
||||
API disabled in the context of log_by_lua*
|
||||
--- error_log eval
|
||||
my $err_log;
|
||||
|
||||
if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$err_log = "http v3 not supported yet";
|
||||
} else {
|
||||
$err_log = "API disabled in the context of log_by_lua*";
|
||||
}
|
||||
|
||||
$err_log;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ bad argument #1 to 'sleep'
|
|||
|
||||
|
||||
=== TEST 5: sleep 0.33 - multi-times in content
|
||||
--- quic_max_idle_timeout: 1.1
|
||||
--- config
|
||||
location /test {
|
||||
content_by_lua '
|
||||
|
|
@ -129,6 +130,7 @@ lua sleep timer expired: "/test?"
|
|||
|
||||
|
||||
=== TEST 6: sleep 0.5 - interleaved by ngx.say() - ended by ngx.sleep
|
||||
--- quic_max_idle_timeout: 2.2
|
||||
--- config
|
||||
location /test {
|
||||
content_by_lua '
|
||||
|
|
@ -156,6 +158,7 @@ lua sleep timer expired: "/test?"
|
|||
|
||||
|
||||
=== TEST 7: sleep 0.5 - interleaved by ngx.say() - not ended by ngx.sleep
|
||||
--- quic_max_idle_timeout: 0.9
|
||||
--- config
|
||||
location /test {
|
||||
content_by_lua '
|
||||
|
|
|
|||
|
|
@ -6,10 +6,21 @@ BEGIN {
|
|||
if ($ENV{TEST_NGINX_EVENT_TYPE} && $ENV{TEST_NGINX_EVENT_TYPE} ne 'poll') {
|
||||
$SkipReason = "unavailable for the event type '$ENV{TEST_NGINX_EVENT_TYPE}'";
|
||||
|
||||
} elsif ($ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$SkipReason = "http3 does not support mockeagain";
|
||||
|
||||
} elsif ($ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
$SkipReason = "http2 does not support mockeagain";
|
||||
|
||||
} else {
|
||||
$ENV{TEST_NGINX_POSTPONE_OUTPUT} = 1;
|
||||
$ENV{TEST_NGINX_EVENT_TYPE} = 'poll';
|
||||
$ENV{MOCKEAGAIN}='w'
|
||||
if ($ENV{LD_PRELOAD} && $ENV{LD_PRELOAD} =~ /\bmockeagain\.so\b/) {
|
||||
$ENV{TEST_NGINX_POSTPONE_OUTPUT} = 1;
|
||||
$ENV{TEST_NGINX_EVENT_TYPE} = 'poll';
|
||||
$ENV{MOCKEAGAIN}='w'
|
||||
} else {
|
||||
$SkipReason = "'mockeagain.so' does not appear to be preloaded "
|
||||
. "with 'LD_PRELOAD'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,3 +71,157 @@ waiting body filter busy buffer to be sent
|
|||
lua say response has busy bufs
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
||||
|
||||
|
||||
=== TEST 2: arg[1] not change and say long string
|
||||
--- config
|
||||
location /t {
|
||||
header_filter_by_lua_block {ngx.header.content_length = nil}
|
||||
body_filter_by_lua_block {
|
||||
local function anyting_not_change_arg1()
|
||||
return
|
||||
end
|
||||
anyting_not_change_arg1()
|
||||
}
|
||||
content_by_lua_block {
|
||||
for i = 1, 100 do
|
||||
ngx.say("12345678901234567890")
|
||||
end
|
||||
}
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_body eval
|
||||
("12345678901234567890\n" x 100)
|
||||
--- no_error_log
|
||||
[error]
|
||||
[alert]
|
||||
[crit]
|
||||
|
||||
|
||||
|
||||
=== TEST 3: arg[1] not change and chunked_transfer_encoding off
|
||||
--- config
|
||||
location /t {
|
||||
header_filter_by_lua_block {ngx.header.content_length = nil}
|
||||
body_filter_by_lua_block {
|
||||
local function anyting_not_change_arg1()
|
||||
return
|
||||
end
|
||||
anyting_not_change_arg1()
|
||||
}
|
||||
chunked_transfer_encoding off;
|
||||
content_by_lua_block {
|
||||
for i = 1, 100 do
|
||||
ngx.say("12345678901234567890123456789012345678901234567890".."_"..tostring(i/3))
|
||||
end
|
||||
}
|
||||
}
|
||||
--- request
|
||||
GET /t
|
||||
--- response_body
|
||||
12345678901234567890123456789012345678901234567890_0.33333333333333
|
||||
12345678901234567890123456789012345678901234567890_0.66666666666667
|
||||
12345678901234567890123456789012345678901234567890_1
|
||||
12345678901234567890123456789012345678901234567890_1.3333333333333
|
||||
12345678901234567890123456789012345678901234567890_1.6666666666667
|
||||
12345678901234567890123456789012345678901234567890_2
|
||||
12345678901234567890123456789012345678901234567890_2.3333333333333
|
||||
12345678901234567890123456789012345678901234567890_2.6666666666667
|
||||
12345678901234567890123456789012345678901234567890_3
|
||||
12345678901234567890123456789012345678901234567890_3.3333333333333
|
||||
12345678901234567890123456789012345678901234567890_3.6666666666667
|
||||
12345678901234567890123456789012345678901234567890_4
|
||||
12345678901234567890123456789012345678901234567890_4.3333333333333
|
||||
12345678901234567890123456789012345678901234567890_4.6666666666667
|
||||
12345678901234567890123456789012345678901234567890_5
|
||||
12345678901234567890123456789012345678901234567890_5.3333333333333
|
||||
12345678901234567890123456789012345678901234567890_5.6666666666667
|
||||
12345678901234567890123456789012345678901234567890_6
|
||||
12345678901234567890123456789012345678901234567890_6.3333333333333
|
||||
12345678901234567890123456789012345678901234567890_6.6666666666667
|
||||
12345678901234567890123456789012345678901234567890_7
|
||||
12345678901234567890123456789012345678901234567890_7.3333333333333
|
||||
12345678901234567890123456789012345678901234567890_7.6666666666667
|
||||
12345678901234567890123456789012345678901234567890_8
|
||||
12345678901234567890123456789012345678901234567890_8.3333333333333
|
||||
12345678901234567890123456789012345678901234567890_8.6666666666667
|
||||
12345678901234567890123456789012345678901234567890_9
|
||||
12345678901234567890123456789012345678901234567890_9.3333333333333
|
||||
12345678901234567890123456789012345678901234567890_9.6666666666667
|
||||
12345678901234567890123456789012345678901234567890_10
|
||||
12345678901234567890123456789012345678901234567890_10.333333333333
|
||||
12345678901234567890123456789012345678901234567890_10.666666666667
|
||||
12345678901234567890123456789012345678901234567890_11
|
||||
12345678901234567890123456789012345678901234567890_11.333333333333
|
||||
12345678901234567890123456789012345678901234567890_11.666666666667
|
||||
12345678901234567890123456789012345678901234567890_12
|
||||
12345678901234567890123456789012345678901234567890_12.333333333333
|
||||
12345678901234567890123456789012345678901234567890_12.666666666667
|
||||
12345678901234567890123456789012345678901234567890_13
|
||||
12345678901234567890123456789012345678901234567890_13.333333333333
|
||||
12345678901234567890123456789012345678901234567890_13.666666666667
|
||||
12345678901234567890123456789012345678901234567890_14
|
||||
12345678901234567890123456789012345678901234567890_14.333333333333
|
||||
12345678901234567890123456789012345678901234567890_14.666666666667
|
||||
12345678901234567890123456789012345678901234567890_15
|
||||
12345678901234567890123456789012345678901234567890_15.333333333333
|
||||
12345678901234567890123456789012345678901234567890_15.666666666667
|
||||
12345678901234567890123456789012345678901234567890_16
|
||||
12345678901234567890123456789012345678901234567890_16.333333333333
|
||||
12345678901234567890123456789012345678901234567890_16.666666666667
|
||||
12345678901234567890123456789012345678901234567890_17
|
||||
12345678901234567890123456789012345678901234567890_17.333333333333
|
||||
12345678901234567890123456789012345678901234567890_17.666666666667
|
||||
12345678901234567890123456789012345678901234567890_18
|
||||
12345678901234567890123456789012345678901234567890_18.333333333333
|
||||
12345678901234567890123456789012345678901234567890_18.666666666667
|
||||
12345678901234567890123456789012345678901234567890_19
|
||||
12345678901234567890123456789012345678901234567890_19.333333333333
|
||||
12345678901234567890123456789012345678901234567890_19.666666666667
|
||||
12345678901234567890123456789012345678901234567890_20
|
||||
12345678901234567890123456789012345678901234567890_20.333333333333
|
||||
12345678901234567890123456789012345678901234567890_20.666666666667
|
||||
12345678901234567890123456789012345678901234567890_21
|
||||
12345678901234567890123456789012345678901234567890_21.333333333333
|
||||
12345678901234567890123456789012345678901234567890_21.666666666667
|
||||
12345678901234567890123456789012345678901234567890_22
|
||||
12345678901234567890123456789012345678901234567890_22.333333333333
|
||||
12345678901234567890123456789012345678901234567890_22.666666666667
|
||||
12345678901234567890123456789012345678901234567890_23
|
||||
12345678901234567890123456789012345678901234567890_23.333333333333
|
||||
12345678901234567890123456789012345678901234567890_23.666666666667
|
||||
12345678901234567890123456789012345678901234567890_24
|
||||
12345678901234567890123456789012345678901234567890_24.333333333333
|
||||
12345678901234567890123456789012345678901234567890_24.666666666667
|
||||
12345678901234567890123456789012345678901234567890_25
|
||||
12345678901234567890123456789012345678901234567890_25.333333333333
|
||||
12345678901234567890123456789012345678901234567890_25.666666666667
|
||||
12345678901234567890123456789012345678901234567890_26
|
||||
12345678901234567890123456789012345678901234567890_26.333333333333
|
||||
12345678901234567890123456789012345678901234567890_26.666666666667
|
||||
12345678901234567890123456789012345678901234567890_27
|
||||
12345678901234567890123456789012345678901234567890_27.333333333333
|
||||
12345678901234567890123456789012345678901234567890_27.666666666667
|
||||
12345678901234567890123456789012345678901234567890_28
|
||||
12345678901234567890123456789012345678901234567890_28.333333333333
|
||||
12345678901234567890123456789012345678901234567890_28.666666666667
|
||||
12345678901234567890123456789012345678901234567890_29
|
||||
12345678901234567890123456789012345678901234567890_29.333333333333
|
||||
12345678901234567890123456789012345678901234567890_29.666666666667
|
||||
12345678901234567890123456789012345678901234567890_30
|
||||
12345678901234567890123456789012345678901234567890_30.333333333333
|
||||
12345678901234567890123456789012345678901234567890_30.666666666667
|
||||
12345678901234567890123456789012345678901234567890_31
|
||||
12345678901234567890123456789012345678901234567890_31.333333333333
|
||||
12345678901234567890123456789012345678901234567890_31.666666666667
|
||||
12345678901234567890123456789012345678901234567890_32
|
||||
12345678901234567890123456789012345678901234567890_32.333333333333
|
||||
12345678901234567890123456789012345678901234567890_32.666666666667
|
||||
12345678901234567890123456789012345678901234567890_33
|
||||
12345678901234567890123456789012345678901234567890_33.333333333333
|
||||
--- no_error_log
|
||||
[error]
|
||||
[alert]
|
||||
[crit]
|
||||
|
|
|
|||
|
|
@ -482,6 +482,8 @@ stack traceback:
|
|||
in function 'error'
|
||||
in function 'bar'
|
||||
in function 'foo'
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
|
|
@ -524,6 +526,8 @@ GET /lua?a=1&b=2
|
|||
--- ignore_response
|
||||
--- 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: \(95\) HTTP\/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
|
|
@ -838,6 +842,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- error_log
|
||||
API disabled in the context of body_filter_by_lua*
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
|
|
@ -860,6 +866,8 @@ failed to load inlined Lua code: body_filter_by_lua(nginx.conf:41):2: unexpected
|
|||
--- no_error_log
|
||||
no_such_error1
|
||||
no_such_error2
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
|
|
@ -890,3 +898,5 @@ failed to load inlined Lua code: body_filter_by_lua(nginx.conf:49):2: unexpected
|
|||
--- no_error_log
|
||||
no_such_error1
|
||||
no_such_error2
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server#
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ __DATA__
|
|||
--- error_code: 500
|
||||
--- error_log
|
||||
bad argument #1 to 'receive' (table expected, got string)
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -51,6 +52,7 @@ bad argument #1 to 'receive' (table expected, got string)
|
|||
--- error_code: 500
|
||||
--- error_log
|
||||
bad argument #1 to 'receiveuntil' (table expected, got number)
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ run_tests();
|
|||
__DATA__
|
||||
|
||||
=== TEST 1: ambiguous boundary patterns (abcabd) - inclusive mode
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -91,6 +92,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 2: ambiguous boundary patterns (abcabdabcabe 4) - inclusive mode
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -162,6 +164,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 3: ambiguous boundary patterns (abcabd) - inclusive mode - small buffers
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
lua_socket_buffer_size 1;
|
||||
|
|
@ -235,6 +238,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 4: inclusive option value nil
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -306,6 +310,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 5: inclusive option value false
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -377,6 +382,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 6: inclusive option value true (aa)
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -448,6 +454,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 7: bad inclusive option value type
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -511,10 +518,13 @@ bad "inclusive" option value type: string
|
|||
--- no_error_log
|
||||
[alert]
|
||||
[warn]
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
=== TEST 8: bad option table
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -578,10 +588,13 @@ bad "inclusive" option value type: string
|
|||
--- no_error_log
|
||||
[alert]
|
||||
[warn]
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP\/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
=== TEST 9: ambiguous boundary patterns (--abc), small buffer
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
@ -658,6 +671,7 @@ close: 1 nil
|
|||
|
||||
|
||||
=== TEST 10: ambiguous boundary patterns (--abc), small buffer, mixed by other reading calls
|
||||
--- no_http2
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
|
|
|
|||
|
|
@ -143,12 +143,15 @@ GET /t
|
|||
|
||||
|
||||
=== TEST 3: access a TCP interface
|
||||
test-nginx use the same port for tcp(http) and udp(http3)
|
||||
so need to change to a port that is not listen by any app.
|
||||
default port range:
|
||||
net.ipv4.ip_local_port_range = 32768 60999
|
||||
choose a port greater than 61000 should be less race.
|
||||
--- config
|
||||
server_tokens off;
|
||||
location /t {
|
||||
#set $port 5000;
|
||||
set $port $TEST_NGINX_SERVER_PORT;
|
||||
#set $port 1234;
|
||||
set $port 65432;
|
||||
|
||||
content_by_lua '
|
||||
local socket = ngx.socket
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ PUT
|
|||
|
||||
|
||||
=== TEST 8: set GET to HEAD
|
||||
--- no_http2
|
||||
--- config
|
||||
location /t {
|
||||
rewrite_by_lua '
|
||||
|
|
@ -209,6 +210,8 @@ main: GET
|
|||
|
||||
|
||||
=== TEST 10: set HEAD to GET
|
||||
XXX: does http3 do not support set HEAD to GET??
|
||||
--- no_http2
|
||||
--- config
|
||||
location /t {
|
||||
rewrite_by_lua '
|
||||
|
|
@ -223,10 +226,13 @@ main: GET
|
|||
method: GET
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
=== TEST 11: set GET to WebDAV methods
|
||||
XXX: does http3 do not support change HEAD method?
|
||||
--- no_http2
|
||||
--- config
|
||||
location /t {
|
||||
content_by_lua '
|
||||
|
|
@ -262,3 +268,4 @@ method: PATCH
|
|||
method: TRACE
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ cc3: 2
|
|||
|
||||
|
||||
=== TEST 3: basic coroutine and cosocket
|
||||
access the public network is unstable, need a bigger timeout
|
||||
--- quic_max_idle_timeout: 4
|
||||
--- config
|
||||
resolver $TEST_NGINX_RESOLVER ipv6=off;
|
||||
location /lua {
|
||||
|
|
@ -760,6 +762,8 @@ GET /lua
|
|||
--- ignore_response
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
@ -1695,6 +1699,8 @@ GET /t
|
|||
"stack traceback:",
|
||||
"in function 'co'"
|
||||
]
|
||||
--- 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/
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -962,7 +962,7 @@ received: OK
|
|||
content_by_lua '
|
||||
local function f()
|
||||
local sock = ngx.socket.udp()
|
||||
local ok, err = sock:setpeername("127.0.0.1", 12345)
|
||||
local ok, err = sock:setpeername("127.0.0.1", $TEST_NGINX_RAND_PORT_1)
|
||||
local bytes, err = sock:send("blah")
|
||||
if not bytes then
|
||||
ngx.say("failed to send query: ", err)
|
||||
|
|
@ -1002,7 +1002,7 @@ delete thread 2
|
|||
delete thread 1
|
||||
)$
|
||||
|
||||
--- udp_listen: 12345
|
||||
--- udp_listen: $TEST_NGINX_RAND_PORT_1
|
||||
--- udp_query: blah
|
||||
--- udp_reply: hello udp
|
||||
--- response_body_like chop
|
||||
|
|
@ -1064,6 +1064,8 @@ body: hello world)$
|
|||
|
||||
|
||||
=== TEST 23: simple user thread with ngx.req.socket()
|
||||
ngx.req.socket() does not support in http3
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
--- config
|
||||
location /lua {
|
||||
content_by_lua '
|
||||
|
|
|
|||
|
|
@ -966,6 +966,7 @@ hello in thread
|
|||
after
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1051,6 +1052,7 @@ hello in thread
|
|||
after
|
||||
--- no_error_log
|
||||
[error]
|
||||
--- skip_eval: 4:$ENV{TEST_NGINX_USE_HTTP3}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1399,6 +1401,8 @@ attempt to abort with pending subrequests
|
|||
--- no_error_log
|
||||
[alert]
|
||||
[warn]
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
|
|
@ -1482,6 +1486,8 @@ free request
|
|||
[alert]
|
||||
[error]
|
||||
[warn]
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
|
|
@ -1565,6 +1571,8 @@ free request
|
|||
[alert]
|
||||
[error]
|
||||
[warn]
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
|
||||
|
||||
|
||||
|
|
@ -1648,3 +1656,5 @@ free request
|
|||
[alert]
|
||||
[error]
|
||||
[warn]
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
|
|
|
|||
|
|
@ -423,3 +423,5 @@ attempt to abort with pending subrequests
|
|||
--- no_error_log
|
||||
[alert]
|
||||
[warn]
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
|
|
|
|||
|
|
@ -277,3 +277,5 @@ attempt to abort with pending subrequests
|
|||
--- no_error_log
|
||||
[alert]
|
||||
[warn]
|
||||
--- curl_error eval
|
||||
qr#curl: \(52\) Empty reply from server|curl: \(95\) HTTP/3 stream 0 reset by server#
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
# vim:set ft= ts=4 sw=4 et fdm=marker:
|
||||
|
||||
use Test::Nginx::Socket::Lua;
|
||||
BEGIN {
|
||||
if ($ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$SkipReason = "client abort detect does not support in http3";
|
||||
} elsif ($ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
$SkipReason = "client abort detect does not support in http2";
|
||||
}
|
||||
}
|
||||
|
||||
use Test::Nginx::Socket::Lua $SkipReason ? (skip_all => $SkipReason) : ();
|
||||
use t::StapThread;
|
||||
|
||||
our $GCScript = <<_EOC_;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
# vim:set ft= ts=4 sw=4 et fdm=marker:
|
||||
|
||||
use Test::Nginx::Socket::Lua;
|
||||
BEGIN {
|
||||
if ($ENV{TEST_NGINX_USE_HTTP3}) {
|
||||
$SkipReason = "client abort detect does not support in http3";
|
||||
} elsif ($ENV{TEST_NGINX_USE_HTTP2}) {
|
||||
$SkipReason = "client abort detect does not support in http2";
|
||||
}
|
||||
}
|
||||
|
||||
use Test::Nginx::Socket::Lua $SkipReason ? (skip_all => $SkipReason) : ();
|
||||
use t::StapThread;
|
||||
|
||||
our $GCScript = <<_EOC_;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue