bug: http2 requests are not supported without content-length header
Current Behavior
http2 requests are not supported without content-length header
Expected Behavior
200
Error Logs
[error] 11650#11650: 87319400 failed to run log_by_lua: /usr/local/apisix/apisix/utils/log-util.lua:188: http2 requests are not supported without content-length header stack traceback: [C]: in function 'get_body_file' /usr/local/apisix/apisix/utils/log-util.lua:188: in function 'get_full_log' /usr/local/apisix/apisix/utils/log-util.lua:243: in function 'get_log_entry' /usr/local/apisix/apisix/plugins/loki-logger.lua:181: in function 'phase_func' /usr/local/apisix/apisix/plugin.lua:1192: in function 'common_phase' /usr/local/apisix/apisix/init.lua:872: in function 'http_log_phase'
Steps to Reproduce
bugfix: revert #2174 and #2237 due to http2 behavior break change #2286 https://github.com/openresty/lua-nginx-module/pull/2286
Environment
APISIX version (3.9.0): Operating system (run uname -a): Linux localhost.localdomain 3.10.0-1160.el7.x86_64 https://github.com/apache/apisix/pull/1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux OpenResty / Nginx version (run openresty -V or nginx -V): nginx version: openresty/1.25.3.1 built by gcc 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) built with OpenSSL 3.2.0 23 Nov 2023 TLS SNI support enabled configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DAPISIX_RUNTIME_VER=1.2.0 -DNGX_GRPC_CLI_ENGINE_PATH=/usr/local/openresty/libgrpc_engine.so -DNGX_HTTP_GRPC_CLI_ENGINE_PATH=/usr/local/openresty/libgrpc_engine.so -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl3/include' --add-module=../ngx_devel_kit-0.3.3 --add-module=../echo-nginx-module-0.63 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.33 --add-module=../ngx_lua-0.10.26 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.37 --add-module=../array-var-nginx-module-0.06 --add-module=../memc-nginx-module-0.20 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../ngx_stream_lua-0.0.14 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/wasmtime-c-api/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl3/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl3/lib' --add-module=/tmp/tmp.HkXszPkFpt/openresty-1.25.3.1/../mod_dubbo-1.0.2 --add-module=/tmp/tmp.HkXszPkFpt/openresty-1.25.3.1/../ngx_multi_upstream_module-1.2.0 --add-module=/tmp/tmp.HkXszPkFpt/openresty-1.25.3.1/../apisix-nginx-module-1.16.0 --add-module=/tmp/tmp.HkXszPkFpt/openresty-1.25.3.1/../apisix-nginx-module-1.16.0/src/stream --add-module=/tmp/tmp.HkXszPkFpt/openresty-1.25.3.1/../apisix-nginx-module-1.16.0/src/meta --add-module=/tmp/tmp.HkXszPkFpt/openresty-1.25.3.1/../wasm-nginx-module-0.7.0 --add-module=/tmp/tmp.HkXszPkFpt/openresty-1.25.3.1/../lua-var-nginx-module-v0.5.3 --add-module=/tmp/tmp.HkXszPkFpt/openresty-1.25.3.1/../grpc-client-nginx-module-v0.5.0 --add-module=/tmp/tmp.HkXszPkFpt/openresty-1.25.3.1/../lua-resty-events-0.2.0 --with-poll_module --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --with-http_v3_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --without-pcre2 --with-http_ssl_module
relevant discussion https://github.com/apache/apisix/pull/11302#discussion_r1619714835, fyi @nic-6443
relevant discussion #11302 (comment), fyi @nic-6443
Got it, I now understand why this sentence was in the document at that time. This restriction does not come from the HTTP/2 or HTTP/3 standards, nor does it affect processing of the HTTP request itself. It is just that the logging plugin needs the content-length header to collect the HTTP body.
Turning off enable_tttp2 can solve this problem enable_http2: false
Refer to https://github.com/apache/apisix/pull/10887/files#r1493494644