search headers_in?
agentzh
agentzh at gmail.com
Wed Sep 14 03:07:24 UTC 2011
On Wed, Sep 14, 2011 at 9:11 AM, Shaun savage <savages at mozapps.com> wrote:
> I am starting to write a new module that uses a header token. I have
> searched google for the answer about "how to seach in headers for a
> name. I want to search for "X-session-token". I am surprised that
> there is not a library function that just does the search,
>
There's common code snippet that does the search :) See
nginx-1.0.6/src/http/modules/ngx_http_proxy_module.c, line 937, for
example.
The ngx_headers_more modules also has this:
https://github.com/agentzh/headers-more-nginx-module/blob/master/src/ngx_http_headers_more_headers_in.c#L184
Another way is to read the nginx variable $http_HEADER on the C land.
See http://wiki.nginx.org/HttpCoreModule#.24http_HEADER
> As I understand it now every module that wants to search for a header
> writes it own search function?
Sort of. It's simple enough.
> Is there a "library search function"?
>
Not any that I'm aware of :)
> once I have the session token I use memcached in the PREACCESS phase to
> load the session info, then in the ACCESS phase check the access permission.
>
Just be sure you use a non-blocking approach to access memcached. You
can take the ngx_srcache module for an example:
http://wiki.nginx.org/HttpSRCacheModule
even though it can also work with other backends like ngx_redis2 and
ngx_redis :)
Regards,
-agentzh
More information about the nginx-devel
mailing list