ngx_http_send_special_response

Maxim Dounin mdounin at mdounin.ru
Mon Apr 16 15:57:16 UTC 2012


Hello!

On Mon, Apr 16, 2012 at 08:14:25AM -0700, hagai avrahami wrote:

> Hi
> Thanks
> 
> The redirect response is from content handler context.
> 
> Using the code you added 
> 
> cause Nginx to send back the Error Page (302) with 
> Content-Length and Content-Type ("test/html") (And I am trying 
> avoid that) without Body

Ah, sorry, I missed you want to send 302 with an empty body, not 
just 302.  Then instead of

    return NGX_HTTP_MOVED_TEMPORARY;

you have to send actual response youself, like this:

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

    rc = ngx_http_send_header(r);

    if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
        return rc;
    }

    return ngx_http_send_special(r, NGX_HTTP_LAST);

Maxim Dounin



More information about the nginx mailing list