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


##########
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:
   > can we explicitly calculate the content_length and add it as a header to 
fix this issue?
   For the HTTP `GET` request, there is no request body.



##########
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:
   > can we explicitly calculate the content_length and add it as a header to 
fix this issue?
   
   For the HTTP `GET` request, there is no request body.



-- 
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