Welcome! Log In Create A New Profile

Advanced

Persistent data accross rewrite

Thibault Koechlin
August 18, 2011 12:42PM
Hello List,

I'm currently working on a module that needs to parse every incoming
request, but only once. In the past, I was relying on r->internal to
decide if I need to parse the request or not, but my assumption was
wrong (I was naive and thinking I can always catch the request before it
goes "internal").

I figured out that if there is some rewrite (and probably in some other
cases), as my module is registered in the ACCESS phase, the r->internal
flag will be set when the request comes to the ACCESS phase (as the
rewrite phase is processed earlier and sets the r->internal flag). As
well, the module's CTX doesn't 'survive' to rewrite, so I cannot use
this neither.

I am looking for a way to keep "persistent" data across the whole
request life, some data that will not disappear with rewrites etc.
Actually, I just want to know if I already parsed the request or not, to
be sure to parse it only once. This data can be accessible only by my
module, that's not an issue.

I had a look at ngx_http_variable, but I'm afraid it's not adapted to my
needs, as it's persistent, and aimed at being accessed from config file,
while I just need a flag to say "this request has already been parsed,
don't parse it" or "this request has not been parsed, parse it, and set
the flag to said it has been parsed".

Except some (terribly wrong and dirty) tricks (like adding a field to
ngx_http_request_t, using global variables ...), I didn't find any way
to do so.

Can someone point me to something that might allow me to keep a 'flag'
for the whole request life ?


Regards,

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Persistent data accross rewrite

Thibault Koechlin 1918 August 18, 2011 12:42PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 291
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready