Reading "Accept" header from module

Maxim Dounin mdounin at mdounin.ru
Wed Feb 11 02:38:45 MSK 2009


Hello!

On Tue, Feb 10, 2009 at 04:42:08PM +0000, Chris Farmiloe wrote:

> Is the "Accept" header content made available on the request struct  
> anywhere? Or if there is an easy way to grab it from the raw headers?
>
> .... defining NGX_HTTP_HEADERS seems to give me unpredictable results  
> when reading the data on request struct.

It should be in r->headers_in->accept.  Please note that 
NGX_HTTP_HEADERS have to be defined for the whole nginx build, not 
just your module.

Alternatively, you may just lookup $http_accept variable via 
ngx_http_get_variable().  This will work even without 
NGX_HTTP_HEADERS defined (and will trigger logic in 
ngx_http_variable_unknown_header_in() for arbitrary http header 
lookup).

Maxim Dounin





More information about the nginx mailing list