[dev] http phase handler
Igor Sysoev
is at rambler-co.ru
Wed Dec 5 21:09:16 MSK 2007
On Wed, Dec 05, 2007 at 06:32:23PM +0100, Manlio Perillo wrote:
> I'm interested in how HTTP phases handlers works in nginx.
>
> I would like to add support, in mod_wsgi, to NGX_HTTP_PREACCESS_PHASE,
> NGX_HTTP_ACCESS_PHASE and NGX_HTTP_CONTENT_PHASE.
>
> I'm reading the sources but I'm not sure to understand how a phase
> handler terminates.
>
> With a request handler, the handler can return NGX_DONE and then call
> ngx_http_finalize_request, but what about a phase handler?
All phase handlers should simpy return value
NGX_OK/NGX_DECLINED/NGX_HTTP_FORBIDDEN/etc.
In the context phase there may run a single defined content handler (perl,
proxy_pass, fastcgi_pass, memcached_pass, flv, empty_gif) or stack
of handlers: index, autoindex, dav, static.
If a defined handler calls finally ngx_http_finalize_request(NGX_DECLINED),
then nginx goes to the stack of handlers. Now only perl can do this.
The preaccess phase is for generic handlers:
on NGX_OK it goes to a next phase,
on NGX_DECLINED it goes to a next handler in the same phase,
on NGX_AGAIN/NGX_DONE it simply return,
on NGX_ERROR or NGX_HTTP_... it calls ngx_http_finalize_request()
The access phase is special to handle NGX_OK/NGX_DECLINED depending on
satisfy_any. However, I'm going to change it, because now:
location / {
satisfy_any on;
auth_basic ...
# no allow/deny rules
}
does not ask username/password.
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list