add_header for 206?

Maxim Dounin mdounin at mdounin.ru
Sat Nov 26 23:53:07 UTC 2011


Hello!

On Fri, Nov 25, 2011 at 10:36:21PM +0000, Richard Kearsley wrote:

> Quote from wiki:
> 
> Add_header
> "Adds headers to the HTTP response when the response code is equal to 200, 204, 301, 302 or 304."
> 
> Any reason we missing 206?

I tend to think it was just forgotten, probably because nginx's 
own range filter (which will generate 206 from 200) only appears 
later in headers filter chain.  Therefore nginx's own 206 will 
have headers added via add_header, while proxied 206 responses 
won't.

Trivial patch:

diff --git a/src/http/modules/ngx_http_headers_filter_module.c b/src/http/modules/ngx_http_headers_filter_module.c
--- a/src/http/modules/ngx_http_headers_filter_module.c
+++ b/src/http/modules/ngx_http_headers_filter_module.c
@@ -145,6 +145,7 @@ ngx_http_headers_filter(ngx_http_request
         || r != r->main
         || (r->headers_out.status != NGX_HTTP_OK
             && 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_NOT_MODIFIED))

Maxim Dounin



More information about the nginx mailing list