Sn0rt commented on code in PR #10425:
URL: https://github.com/apache/apisix/pull/10425#discussion_r1411850592


##########
t/plugin/forward-auth.t:
##########
@@ -374,3 +401,41 @@ GET /hello
 --- more_headers
 Authorization: 111
 --- error_code: 200
+
+
+
+=== TEST 13: test large body
+--- config
+    location /t {
+        content_by_lua_block {
+            local t    = require("lib.test_admin")
+            local http = require("resty.http")
+            local httpc = http.new()
+
+            local tempFileName = os.tmpname()
+            local file = io.open(tempFileName, "wb")
+
+            local fileSizeInBytes = 11 * 1024 * 1024 -- 11MB
+            for i = 1, fileSizeInBytes do
+                file:write(string.char(0))
+            end
+            file:close()
+
+            local large_body = t.read_file(tempFileName)
+            local uri = "http://127.0.0.1:"; .. ngx.var.server_port
+            .. "/large-body"
+            local res, err = httpc:request_uri(uri,
+                {
+                    method = "POST",
+                    body = large_body,
+                    headers = {
+                        ["Authorization"] = "large-body",
+                        ["Content-Type"] = "application/x-www-form-urlencoded"
+                    }
+                }
+            )
+
+            ngx.say(res.body)

Review Comment:
   ```
   2023/12/01 17:40:30 [warn] 92639#13489089: *46 a client request body is 
buffered to a temporary file 
/Users/guohao/workspace/apisix/t/servroot/client_body_temp/0000000001, client: 
127.0.0.1, server: localhost, request: "POST /auth HTTP/1.1", host: 
"127.0.0.1:1984"
   2023/12/01 17:40:30 [info] 92639#13489089: *46 [lua] request.lua:302: 
get_body(): attempt to read body from file: 
/Users/guohao/workspace/apisix/t/servroot/client_body_temp/0000000001, client: 
127.0.0.1, server: localhost, request: "POST /auth HTTP/1.1", host: 
"127.0.0.1:1984"
   2023/12/01 17:40:30 [warn] 92639#13489089: *42 [lua] plugin.lua:1159: 
run_plugin(): forward-auth exits with http status code 400, client: 127.0.0.1, 
server: localhost, request: "POST /large-body HTTP/1.1", host: "127.0.0.1:1984"
   2023/12/01 17:40:30 [warn] 92639#13489089: *3 using uninitialized 
"upstream_scheme" variable while logging request, client: 127.0.0.1, server: 
localhost, request: "GET /t HTTP/1.1", host: "localhost"
   ```



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