How to send a empty response

georgexsh nginx-forum at nginx.us
Tue Aug 11 13:42:07 MSD 2009


Hi, all, I'am working a module that simply send out a few set cookie header
the module works fine under 'HEAD' request, but for 'GET' request, I find that some bytes must be put into output buffer or nginx will not write anything to clien, eg:

r->headers_out.status = NGX_HTTP_OK;
r->headers_out.content_length_n = 0;

b->pos = (u_char *) ' ';
b->last = b->pos + 1;
b->memory = 1;
b->last_buf = 1;

out.buf = b;
out.next = NULL;

if (ngx_http_send_header(r))
    return NGX_ERROR;
return ngx_http_output_filter(r, &out);


but in some modules, this job could be done by just simply call ngx_http_send_header(), but does't work for me, any ideas?

if (r != r->main && of.size == 0) {
    return ngx_http_send_header(r);
}


Posted at Nginx Forum: http://forum.nginx.org/read.php?2,4859,4859#msg-4859






More information about the nginx mailing list