resty.upload和ngx.req.get_post_args()

孤者浪人 提交于 2020-03-02 17:16:55

在使用了resty.upload模块的同时使用 ngx.req.get_post_args() 的时候, 会出错,error log如下:

2013/09/25 22:32:43 [notice] 8763#0: signal process started
2013/09/25 22:32:48 [warn] 8764#0: *14 a client request body is buffered to a temporary file /usr/local/openresty/nginx/client_body_temp/0000000003, client: 113.77.83.178, server: localhost, request: "POST /upload?action=do&subaction=xx HTTP/1.1", host: "xxx.xicp.net:8089", referrer: "http://xxx.xicp.net:8089/"
2013/09/25 22:32:49 [error] 8764#0: *14 lua entry thread aborted: runtime error: /usr/local/openresty/nginx/html2/pt_upload.lua:35: requesty body in temp file not supported
stack traceback:
coroutine 0:
[C]: in function 'get_post_args'

不知为何,二者不能同时使用,看log是因为request body被其中一个独占了,另外一个就没有权限读取了?

看到了有人遇到了同样的问题,agentzh给出了回答:

这个错误消息明确地指出了你的请求体因为过大(即超过你的 client_body_buffer_size 配置)而被 nginx 自动缓冲到了临时文件中,而 ngx.req.get_post_args() 并不支持从文件加载所有的参数(因为可能占用过多的内存)。 你可以考虑适大加大你的 nginx 的 client_body_buffer_size 配置: http://wiki.nginx.org/HttpCoreModule#client_body_buffer_size 当 client_body_buffer_size 配置为和 client_max_body_size 一样大时,nginx 就永远不会把请求体缓冲到文件系统了(但也要仔细内存占用)。 Best regards, -agentzh
在修改了client_body_buffer_size 配置和 client_max_body_size 一样大之后,另外一个错误log出现了:

2013/09/25 23:33:14 [error] 9303#0: *16 [lua] pt_upload.lua:140: uploadTest(): failed to new upload: request body already exists, client: 113.77.83.178, server: localhost, request: "POST /upload?action=do&subaction=xx HTTP/1.1", host: "xx.xicp.net:8089", referrer: "http://xx.xicp.net:8089/"

这估计是和我之前猜测的request body 不能被二者一起读取有些关系.

待解决中....

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!