You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "Goend (via GitHub)" <gi...@apache.org> on 2026/04/17 06:29:03 UTC

[PR] fix(ext-plugin-post-resp): avoid H2/H3 Content-Length check when read… [apisix]

Goend opened a new pull request, #13243:
URL: https://github.com/apache/apisix/pull/13243

   ### Description
   
     This PR fixes an issue in `ext-plugin-post-resp` when handling HTTP/2 and HTTP/3 requests without a `Content-Length` header.
   
     Currently, `ext-plugin-post-resp` replays the original client request to upstream and reads the request body via `core.request.get_body()`. After the behavior introduced in #10887, `core.request.get_body()` rejects
     HTTP/2 and HTTP/3 requests that do not contain a `Content-Length` header.
   
     This causes valid body-less requests such as normal `GET` requests over HTTP/2 to fail unexpectedly with `502` when `ext-plugin-post-resp` is enabled.
   
     This PR avoids using `core.request.get_body()` in `ext-plugin-post-resp` and reads the request body directly from the Nginx request APIs instead. As a result, body-less HTTP/2 and HTTP/3 requests are handled
     correctly, while requests that actually contain a body can still be forwarded as expected.
   
     #### Which issue(s) this PR fixes:
   
     Fixes #13237
   
     ### Checklist
   
     - [x] I have explained the need for this PR and the problem it solves
     - [x] I have explained the changes or the new features added to this PR
     - [ ] I have added tests corresponding to this change
     - [ ] I have updated the documentation to reflect this change
     - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(ext-plugin-post-resp): avoid H2/H3 Content-Length check when read… [apisix]

Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan closed pull request #13243: fix(ext-plugin-post-resp): avoid H2/H3 Content-Length check when read…
URL: https://github.com/apache/apisix/pull/13243


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(ext-plugin-post-resp): avoid H2/H3 Content-Length check when read… [apisix]

Posted by "AlinsRan (via GitHub)" <gi...@apache.org>.
AlinsRan commented on PR #13243:
URL: https://github.com/apache/apisix/pull/13243#issuecomment-4889999480

   Fixed: #13428. I will close this PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(ext-plugin-post-resp): avoid H2/H3 Content-Length check when read… [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop commented on code in PR #13243:
URL: https://github.com/apache/apisix/pull/13243#discussion_r3135322485


##########
apisix/core/request.lua:
##########
@@ -290,15 +290,6 @@ function _M.get_body(max_size, ctx)
         end
     end
 
-    -- check content-length header for http2/http3

Review Comment:
   This modification is too extensive, we recommend:
   
   1. **Narrow the fix to `ext-plugin-post-resp.lua`**: bypass `core.request.get_body()` and use `ngx.req.read_body()` + `ngx.req.get_body_data()` directly for the upstream replay request
   2. **Or refine the check in `get_body()`**: skip the Content-Length check for request methods that typically have no body (GET, HEAD, DELETE, OPTIONS), while keeping it for POST/PUT/PATCH
   3. **Add targeted tests**: add H2 test cases specifically for `ext-plugin-post-resp` to cover the reported scenario, and verify no regression in other H2-dependent plugins (e.g., `grpc-web`, `batch-requests`)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(ext-plugin-post-resp): avoid H2/H3 Content-Length check when read… [apisix]

Posted by "Goend (via GitHub)" <gi...@apache.org>.
Goend commented on code in PR #13243:
URL: https://github.com/apache/apisix/pull/13243#discussion_r3135767208


##########
apisix/core/request.lua:
##########
@@ -290,15 +290,6 @@ function _M.get_body(max_size, ctx)
         end
     end
 
-    -- check content-length header for http2/http3

Review Comment:
     @Baoyuantop Thanks for the review. I initially took the same approach of only bypassing the check in ext-plugin-post-resp, but after digging into the upstream lua-nginx-module, I believe removing the check from get_body() is actually the correct fix.                                                                                                                                                    This Content-Length validation was originally added to align with lua-nginx-module's documented limitation (see https://github.com/openresty/lua-nginx-module/pull/2237). However, upstream has since  relaxed this restriction: - https://github.com/openresty/lua-nginx-module/commit/e0d19f787e74ce3ffbb9b9c5abad02fd6ea81f41 partially lifted it - https://github.com/openresty/lua-nginx-module/commit/6e29c1a96e641ea3e3498b1524baeaa28d3ab58c further relaxed it, and the docs no longer state that ngx.req.read_body() requires Content-Length for  H2/H3                                                  
                                                                                                                                                Since the underlying layer no longer enforces this restriction, keeping the check in get_body() makes APISIX stricter than the runtime — it blocks valid H2/H3 requests across all 20+ plugins that    call get_body(), not just ext-plugin-post-resp. Removing it here is not "too extensive" — it's removing a guard that no longer serves its purpose.
    I'll add targeted H2 tests for ext-plugin-post-resp as suggested. Let me know your thoughts. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(ext-plugin-post-resp): avoid H2/H3 Content-Length check when read… [apisix]

Posted by "nic-6443 (via GitHub)" <gi...@apache.org>.
nic-6443 commented on PR #13243:
URL: https://github.com/apache/apisix/pull/13243#issuecomment-4676905567

   The root cause was removed on master by #13428 — the H2/H3 Content-Length guard in `core.request.get_body()` is gone entirely, so ext-plugin-post-resp no longer 502s on HTTP/2 requests without a body, and a plugin-local `read_body()` workaround isn't needed anymore (it would also bypass `get_body()`'s max_size handling). I think this can be closed; the fix ships in the next release after 3.16.0.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org