File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -3168,9 +3168,9 @@ ngx_http_lua_req_socket(lua_State *L)
31683168 }
31693169
31703170 if (!r -> header_sent ) {
3171- lua_pushnil ( L );
3172- lua_pushliteral ( L , " response header not sent yet" );
3173- return 2 ;
3171+ /* prevent other parts of nginx from sending out
3172+ * the response header */
3173+ r -> header_sent = 1 ;
31743174 }
31753175
31763176 dd ("ctx acquired raw req socket: %d" , ctx -> acquired_raw_req_socket );
@@ -3212,6 +3212,7 @@ ngx_http_lua_req_socket(lua_State *L)
32123212
32133213 ctx -> acquired_raw_req_socket = 1 ;
32143214 r -> keepalive = 0 ;
3215+ r -> lingering_close = 1 ;
32153216#endif
32163217
32173218 } else {
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ use t::TestNginxLua;
55
66repeat_each(2);
77
8- plan tests => repeat_each() * 26 ;
8+ plan tests => repeat_each() * 29 ;
99
1010our $HtmlDir = html_dir;
1111
@@ -119,18 +119,26 @@ lua raw req socket tcp_nodelay
119119 ngx.log(ngx.ERR, "server: failed to get raw req socket: ", err)
120120 return
121121 end
122+ local ok, err = sock:send("HTTP/1.1 200 OK\\r\\nContent-Length: 5\\r\\n\\r\\nhello")
123+ if not ok then
124+ ngx.log(ngx.ERR, "failed to send: ", err)
125+ return
126+ end
122127 ';
123128 }
124129
125130--- raw_request eval
126131"GET /t HTTP/1.0\r
127132Host: localhost\r
128- Upgrade: mysocket \r
133+ Content-Length: 5 \r
129134\r
130135hello"
131- --- ignore_response
132- --- error_log
133- server: failed to get raw req socket: response header not sent yet
136+ --- response_headers
137+ Content-Length: 5
138+ --- response_body chop
139+ hello
140+ --- no_error_log
141+ [error]
134142
135143
136144
@@ -144,7 +152,7 @@ server: failed to get raw req socket: response header not sent yet
144152 local sock, err = ngx.req.socket(true)
145153 if not sock then
146154 ngx.log(ngx.ERR, "server: failed to get raw req socket: ", err)
147- return
155+ return ngx.exit(500)
148156 end
149157 ';
150158 }
You can’t perform that action at this time.
0 commit comments