Skip to content

bug: 502 error when using ext-plugin-post-resp due to HTTP/2/HTTP/3 request without Content-Length header #13237

@Goend

Description

@Goend

Current Behavior

  1. Enable http2 on the APISIX gateway listener.
  2. Configure a route or Ingress that uses the ext-plugin-post-resp plugin.
  3. Make sure the request reaches the ext-plugin-post-resp code path.
    For example, attach an ApisixPluginConfig with ext-plugin-post-resp enabled to an Ingress.
  4. Send an HTTP/2 GET request that has no request body and no Content-Length header.
    Example:

curl -k -i --http2 'https://(host)/xx/'

  1. Observe that APISIX returns 502.

Relevant code path

  • apisix/plugins/ext-plugin-post-resp.lua
  • apisix/core/request.lua

The failure is triggered by logic equivalent to:

if (var.server_protocol == "HTTP/2.0" or var.server_protocol == "HTTP/3.0")
and not content_length then
return nil, "HTTP2/HTTP3 request without a Content-Length header"
end

Expected Behavior

The request should not fail.
For an HTTP/2 or HTTP/3 GET request without a body, APISIX should treat the request body as empty and continue normally. Content-Length should not be required in this case.

Error Logs

[lua] ext-plugin-post-resp.lua:153: phase_func(): failed to request: HTTP2/HTTP3 request without a Content-Length header
[lua] plugin.lua:1198: common_phase(): ext-plugin-post-resp exits with http status code 502

Steps to Reproduce

Refer to the Current Behavior section

Environment

  • APISIX version (run apisix version): 3.15.0
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • 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):

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplugin

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions