The "headers_more" module: Set and clear output headers...more than "add"!

agentzh agentzh at gmail.com
Tue Nov 17 13:00:59 MSK 2009


Hi, folks!

After two days' work, I've now got the "headers_more" module passing
the its own test suite. This is an enhanced version of the standard
"headers" module because it provides more utilities like resetting or
clearing output headers. Builtin headers, like "Content-Type",
"Content-Length", and "Server",  are also manipulatable ;)

It also allows you to specify an optional HTTP status code criteria
using the -s option and an optional content type criteria using the -t
option.

Here's some random use cases:

    more_set_headers 'Server: my-server';

    location /foo {
        more_set_headers 'X-MyHeader: blah' 'X-MyHeader2: foo';
        more_set_headers -t 'text/plain text/css' 'Content-Type: text/foo';
        more_set_headers -s '400 404 500 503' 'Foo: Bar';
        more_clear_headers 'Transfer-Encoding' 'Content-Type';
    }

    location /type {
        more_set_headers 'Content-Type: text/plain';
    }

One important TODO is to allow variables within the new headers'
values. That's where "headers_more" is "less" than the standard
"headers" module :P

The Git source repository is here:

    http://github.com/agentzh/headers-more-nginx-module

And you're recommended to use the tarballs for the tagged releases:

    http://github.com/agentzh/headers-more-nginx-module/downloads

Don't hesitate to report any issues that you find ;)

Enjoy!
-agentzh





More information about the nginx mailing list