Tuesday, July 24, 2012

nginx module reply with header only

When testing with a module written for nginx, I have only headers need to send back and no response body.  I set the content length to be zero and finished the module with the following line:
return ngx_http_send_header(r);
The browser was not receiving anything from the server and waiting till time out.  After digged through the nginx source, it seems nginx need to be informed data has been finished with a call to
ngx_http_send_special (r, NGX_HTTP_LAST);
After adding the necessary code and ended the module with a call to ngx_http_send_special(), it works as expected.

No comments: