<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap:break-word;line-break:after-white-space"><div id="bloop_customfont" style="color:rgb(0,0,0);margin:0px"><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"># HG changeset patch</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"># User Alex Zhang <<a href="mailto:zchao1995@gmail.com">zchao1995@gmail.com</a>></span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"># Date 1516079440 -28800</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"># Tue Jan 16 13:10:40 2018 +0800</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"># Node ID 9ca5af970d2296a02acefb3070237c5f52119708</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"># Parent 93abb5a855d6534f0356882f45be49f8c6a95a8b</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">yield 499 while reading client body and client prematurely closed connection.</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"><br></span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">The function ngx_http_do_read_client_request_body returns</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">NGX_HTTP_BAD_REQUEST (client prematurely closed connection),</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">while the 400 status code cannot reflect that client closed connection</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">prematurely. It should return code 499(NGX_HTTP_CLIENT_CLOSED_REQUEST)</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">and it is helpful to troubleshoot some relevant problems.</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"><br></span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">Signed-off-by: Alex Zhang <<a href="mailto:zchao1995@gmail.com">zchao1995@gmail.com</a>></span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"><br></span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">diff -r 93abb5a855d6 -r 9ca5af970d22 src/http/ngx_http_request_body.c</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">--- a/src/http/ngx_http_request_body.c Thu Jan 11 21:43:49 2018 +0300</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">+++ b/src/http/ngx_http_request_body.c Tue Jan 16 13:10:40 2018 +0800</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">@@ -342,14 +342,17 @@</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"> break;</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"> }</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"><br></span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">- if (n == 0) {</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">+ if (n == 0 || n == NGX_ERROR) {</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">+ c->error = 1;</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">+</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">+ if (n == 0) {</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">+ return NGX_HTTP_BAD_REQUEST;</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">+ }</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">+</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"> ngx_log_error(NGX_LOG_INFO, c->log, 0,</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"> "client prematurely closed connection");</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">- }</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"><br></span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">- if (n == 0 || n == NGX_ERROR) {</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">- c->error = 1;</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">- return NGX_HTTP_BAD_REQUEST;</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px">+ return NGX_HTTP_CLIENT_CLOSED_REQUEST;</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"> }</span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"><br></span></font></div><div id="bloop_customfont" style="margin:0px"><font face="Helvetica"><span style="font-size:14px"> rb->buf->last += n;</span></font></div></div><font face="Helvetica"><span style="font-size:14px"><br></span></font><div id="bloop_sign_1516082275818924800" class="bloop_sign"></div></body></html>