Loading...
This site is best viewed in a modern browser with JavaScript enabled.
Something went wrong while trying to load the full version of this site. Try hard-refreshing this page to fix the error.
回复: [openresty] 关于用Lua读取post中的原始数据
marcusxing
多谢版主,明天实验下;)
------------------ 原始邮件 ------------------
发件人:
"agentzh"<age...@gmail.com>;
发送时间:
2012年6月18日(星期一) 晚上10:41
收件人:
"openresty"<openresty@googlegroups.com>;
主题:
Re: [openresty] 关于用Lua读取post中的原始数据
Hello!
2012/6/18 Mr.SlUmP <marc...@qq.com>:
> 看到agentzh的模块提供的不是multipart就是键值对,我想读原始的POST数据,如果读超时了,也要把当前读到的数据发到后端服务器,直接用ngx.req.socket来读吗?
这个需求只能使用 ngx_lua 模块的 ngx.req.socket API 了。
而相比之下,Nginx 核心中的请求体读取函数遇到读取超时错误时就直接返回 408 错误页了(见 nginx 源码中的
src/http/ngx_http_request_body.c 文件中的
ngx_http_read_client_request_body_handler 函数),所以你的代码将没有机会进行善后处理。
ngx.req.socket() 返回的下游 cosocket 对象遇到读取超时时,会返回 'timeout' 错误串给你的 Lua
代码,你从而有机会进行恰当的处理。你甚至可以读一片请求体数据,就发一片给你的后端服务。因为下游 cosocket
对象支持严格的流式(或者说非缓冲)读取请求体数据。
Regards,
-agentzh
--
邮件自: 列表“openresty”,专用于技术讨论!
发言: 请发邮件到 openresty@googlegroups.com
退订: 请发邮件至 openresty+unsubscribe@googlegroups.com
详情: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
建议: 提问的智慧 http://wiki.woodpecker.org.cn/moin/AskForHelp
教程: http://agentzh.org/misc/nginx/agentzh-nginx-tutorials-zhcn.html