Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: apisix missing Transfer-Encoding header when client http body size is not zero #11703

Open
zhendongcmss opened this issue Nov 1, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@zhendongcmss
Copy link
Contributor

zhendongcmss commented Nov 1, 2024

Current Behavior

apisix config

curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
    "uri": "/*",
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "192.168.8.110:8899": 10
        }
    }
}'

python client send chunked request

import requests

def generate_data():
    yield b"123"

url = "http://192.168.8.110:9080"

headers = {
    "Transfer-Encoding": "chunked",
}

response = requests.post(url, headers=headers, data=generate_data())

print(response.text)

using python start a backend server to print receive headers

cat > 8899.py << EOF
#!/usr/bin/env python3
import socket, sys
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = ('0.0.0.0', int(sys.argv[1]) if len(sys.argv) >= 2 else 8899)
print(host)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(host)
sock.listen(100)
while True:
    try:
        conn, addr = sock.accept()
        data = conn.recv(1024 * 1024 * 1024 * 1)
        sys.stdout.write('=' * 5 + str(addr) + '=' * 5)
        sys.stdout.write(data.decode('utf-8'))
        response = b'HTTP/1.1 200 OK\r\nContent-Length: 6\r\nConnection: close\r\n\r\nHello\n'
        conn.sendall(response)
        conn.close()
    except KeyboardInterrupt as e:
        sock.close()
        exit()
    except UnicodeDecodeError as e:
        sys.stdout.write(data)
    except Exception as e:
        sys.stdout.write(str(e))
EOF
  • chmod a+x 8899.py
  • python3 8899.py

test res

  1. upstream receive doesn't inlcude Transfer-Encoding: chunked header
  2. if change yield b"123" to yield b"", client send 0 size body, upstream receive include the Transfer-Encoding: chunked header
  3. I think it maybe nginx issue

Expected Behavior

No response

Error Logs

No response

Steps to Reproduce

as Current Behavior

Environment

  • APISIX version (run apisix version): 2.10.1
  • Operating system (run uname -a): Linux myapisixnode 3.10.0-1160.el7.x86_64 change: added doc of how to load plugin. #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.21.4.2
built by gcc 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
built with OpenSSL 1.1.1s  1 Nov 2022
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DAPISIX_BASE_VER=1.0.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/openssl111/include' --add-module=../ngx_devel_kit-0.3.2 --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.25 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.34 --add-module=../array-var-nginx-module-0.06 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../ngx_stream_lua-0.0.13 --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/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --add-module=/tmp/tmp-new/openresty-1.21.4.2/../mod_dubbo-1.0.2 --add-module=/tmp/tmp-new/openresty-1.21.4.2/../ngx_multi_upstream_module-1.1.1 --add-module=/tmp/tmp-new/openresty-1.21.4.2/../apisix-nginx-module-1.15.0 --add-module=/tmp/tmp-new/openresty-1.21.4.2/../apisix-nginx-module-1.15.0/src/stream --add-module=/tmp/tmp-new/openresty-1.21.4.2/../apisix-nginx-module-1.15.0/src/meta --add-module=/tmp/tmp-new/openresty-1.21.4.2/../wasm-nginx-module-0.6.5 --add-module=/tmp/tmp-new/openresty-1.21.4.2/../lua-var-nginx-module-v0.5.3 --add-module=/tmp/tmp-new/openresty-1.21.4.2/../grpc-client-nginx-module-v0.4.4 --add-module=/tmp/tmp-new/openresty-1.21.4.2/../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 --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 --with-http_ssl_module
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Apache APISIX backlog Nov 1, 2024
@dosubot dosubot bot added the bug Something isn't working label Nov 1, 2024
@zhendongcmss
Copy link
Contributor Author

I raise an issue on nginx repo nginx/nginx#316

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant