zll600 commented on code in PR #10887:
URL: https://github.com/apache/apisix/pull/10887#discussion_r1495793741


##########
apisix/core/request.lua:
##########
@@ -282,6 +282,17 @@ function _M.get_body(max_size, ctx)
         end
     end
 
+    -- TODO: solve this issue correctly.
+    local var = ctx and ctx.var or ngx.var
+    local content_length = tonumber(var.http_content_length) or 0
+    if (var.server_protocol == "HTTP/2.0" or var.server_protocol == "HTTP/3.0")
+        and content_length == 0 then
+        -- 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.
+        return nil
+    end

Review Comment:
   This limitation was introduced by this pr: 
https://github.com/openresty/lua-nginx-module/pull/2237
   The failed test-case is 
https://github.com/apache/apisix/blob/f79c4eba51a96ef7223a045a0d39465c47ab4b71/t/plugin/azure-functions.t#L188
   
   If I remove the patch code, the test-case will fail
   
   ````shell
   apisix/apisix/core/request.lua:296: http2 requests are not supported without 
content-length header" (req 0)
   # stack traceback:
   # coroutine 0:
   #       [C]: in function 'req_read_body'
   ````
   
   then I modified the test case as follows. It will success.
   ````perl
   --- http2
   --- request
   GET /azure
   --- more_headers
   Content-Length: 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to