Removing response headers

Maxim Dounin mdounin at
Tue Jul 2 15:32:25 UTC 2013


On Tue, Jul 02, 2013 at 10:35:11AM -0400, Jeff Kaufman wrote:

> In a header filter, to remove a filter that's already been set, I see
> two options:
> 1. set the header's hash to 0
> 2. actually delete the header from r->headers_out
> The second is much more complex and requires allocating memory (see
> ngx_http_headers_more_rm_header_helper in
> so I'd rather use the first, but is there a reason to prefer the
> second?

The headers more module uses this rather complicated code as it 
tries to modify input headers, which are not expected to be 

As long as you are changing r->headers_out, it's ok to just set 
hash to 0 (note though that special headers like Location or 
Content-Length will also require various special handling).

Maxim Dounin

More information about the nginx-devel mailing list