add_header directive is not working when r->headers_out.status == NGX_HTTP_CREATED
Dmitry Petrov
dmitry.petroff at gmail.com
Tue Mar 19 10:11:08 UTC 2013
Hello
I was trying to add some custom headers via add_header directive to webdav
response and run into the problem: if response code was 201 (file created),
then custom headers weren't added. The reason in that big if statement in
ngx_http_headers_filter doesn't check for NGX_HTTP_CREATED. Is it intended
behavior that custom headers aren't added to 201 responses?
If we want to add headers to any 2xx response, then why just don't change
if ((conf->expires == NGX_HTTP_EXPIRES_OFF && conf->headers == NULL)
|| r != r->main
|| (r->headers_out.status != NGX_HTTP_OK
&& r->headers_out.status != NGX_HTTP_CREATED
&& r->headers_out.status != NGX_HTTP_NO_CONTENT
&& r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT
&& r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY
&& r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY
&& r->headers_out.status != NGX_HTTP_SEE_OTHER
&& r->headers_out.status != NGX_HTTP_NOT_MODIFIED
&& r->headers_out.status != NGX_HTTP_TEMPORARY_REDIRECT))
{
return ngx_http_next_header_filter(r);
}
to
if ((conf->expires == NGX_HTTP_EXPIRES_OFF && conf->headers == NULL)
|| r != r->main
|| r->headers_out.status / 100 != 2)
{
return ngx_http_next_header_filter(r);
}
--
Regards,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130319/aabd9247/attachment-0001.html>
More information about the nginx-devel
mailing list