i use sleep(50) function, then request the server, before the server response, i close the browser, but the corresponding response code is still 200, i hope it would be 499. how to create a HTTP 499 request which let server to record a HTTP 499 access log?
You need to have the whole request sent to Nginx, then close the client connection while Nginx is processing the response. If you are requesting a static file Nginx will be really fast at processing your request, and chances are very low that your connection will stop between the very short window where your request is fully received and the response is not yet available for Nginx.
I've tried with a big inputs from the client, closing before the end of request transmission, that's only an error 400. You really need to close on the short time of Nginx response processing, that's hard.
Unless you use a dynamic language for the response (like PHP via fastcgi) to process the response (or nginx is a reverse proxy to something in your control). Then it's easy to add the
sleep() on the response side.
Simply adding this on top an
Will give you a 30s window of time to close your browser.
127.0.0.1 - - [21/Oct/2016:11:24:23 +0000] "GET / HTTP/1.1" 499 0 "-" "-" "-"