Accessing HTTP request headers in nginx module

Mapper Uno lists at
Tue Apr 1 06:29:48 UTC 2014

I could finally get hold of all the http header fields. A nice link that 
describes how to access the headers

Thanks for all the replies.

Mapper Uno wrote in post #1141373:
> Thanks Maxim for your reply. Since I am newbie, please excuse my
> questions. I am still unable to retrieve the variable.
> All I have in the handler routine is:  ngx_http_request_t *r
> I can see that r->headers_in.headers is a list, but then
> when you say $http_operation, it is confusing me.
> Could you please explain
> Maxim Dounin wrote in post #1141328:
>> Hello!
>> On Fri, Mar 28, 2014 at 01:06:00AM +0100, Mapper Uno wrote:
>>> indicates that these are not "custom" headers. With reference to my
>>> above example, how can I access my custom header "OPERATION" in module
>>> handler ?
>> Please make sure to read not only the first sentence.  Note the
>> "Also there are other variables" in the same paragraph.  The
>> $http_* variables provide access to all headers, including any
>> custom ones.  And it is documented as:
>> $http_name
>> arbitrary request header field; the last part of a variable name
>> is the field name converted to lower case with dashes replaced by
>> underscores
>> Therefore, you may either use the $http_operation variable to
>> access the header you are looking for.  Or you may take a look at
>> the source code to find out how it's implemented.  Take a look at
>> the src/http/ngx_http_variables.c, functions
>> ngx_http_variable_unknown_header_in() and
>> ngx_http_variable_unknown_header() (first one says the header
>> should be searched in r->headers_in.headers list, second one does
>> actual search).
>> --
>> Maxim Dounin

Posted via

More information about the nginx mailing list