Hi,
I've been trying to use ngx.req.socket(true) sockets for pipelined requests but I cannot get it to respond to more than the first pipelined request (/pipelinefail) - as can be seen the example (/pipelinepass) it works fine with just ngx.req.socket(). I wasn't sure if I was missing something, or if the current stable version of OpenResty (or nginx) does not support it yet?
The basic example config:
location = /pipelinefail {
content_by_lua '
ngx.status = 101
ngx.req.read_body()
local sock, err = ngx.req.socket(true)
if not sock then
ngx.log(ngx.ERR, "server: failed to get raw req socket: ", err)
return
end
local ok, err = sock:send("HTTP/1.1 200 OK\\r\\nContent-Length: 5\\r\\n\\r\\nhello")
if not ok then
ngx.log(ngx.ERR, "failed to send: ", err)
return
end
';
}
location = /pipelinepass {
content_by_lua '
ngx.status = 101
ngx.req.read_body()
local sock, err = ngx.req.socket()
if not sock then
ngx.log(ngx.ERR, "server: failed to get raw req socket: ", err)
return
end
local ok, err = ngx.say("200 OK\\r\\nContent-Length: 5\\r\\n\\r\\nhello")
if not ok then
ngx.log(ngx.ERR, "failed to send: ", err)
return
end
';
}
Any comments/help welcome.
Thanks.