summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_variables.c
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2023-05-25 00:27:55 +0800
committerZhidao HONG <z.hong@f5.com>2023-05-25 00:27:55 +0800
commita378f6aa3136ed7ef172b71add31ee62e560df00 (patch)
tree701fc0e0d348a7f08cf37ed1d43cbef1e0e9d909 /src/nxt_http_variables.c
parentce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4 (diff)
downloadunit-a378f6aa3136ed7ef172b71add31ee62e560df00.tar.gz
unit-a378f6aa3136ed7ef172b71add31ee62e560df00.tar.bz2
HTTP: fixed variable caching.
When a variable is accessed in the Unit configuration, the value is cached. This was useful prior to the URI rewrite feature, but now that the URI (more precisely, the request target) can be rewritten, the contents of the variable $uri (which contains the path part of the request target, and is decoded) should not be cached anymore, or at least the cached value should be invalidated after a URI rewrite. Example: { "rewrite": "/prefix$uri", "share": "$uri" } For a request line like GET /foo?bar=baz HTTP/1.1\r\n, the expected file served in the response would be /prefix/foo, but due to the caching issue, Unit currently serves /foo.
Diffstat (limited to '')
-rw-r--r--src/nxt_http_variables.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/nxt_http_variables.c b/src/nxt_http_variables.c
index b73d9151..71f7ff7f 100644
--- a/src/nxt_http_variables.c
+++ b/src/nxt_http_variables.c
@@ -47,54 +47,70 @@ static nxt_var_decl_t nxt_http_vars[] = {
{
.name = nxt_string("dollar"),
.handler = nxt_http_var_dollar,
+ .cacheable = 1,
}, {
.name = nxt_string("request_time"),
.handler = nxt_http_var_request_time,
+ .cacheable = 1,
}, {
.name = nxt_string("method"),
.handler = nxt_http_var_method,
+ .cacheable = 1,
}, {
.name = nxt_string("request_uri"),
.handler = nxt_http_var_request_uri,
+ .cacheable = 1,
}, {
.name = nxt_string("uri"),
.handler = nxt_http_var_uri,
+ .cacheable = 0,
}, {
.name = nxt_string("host"),
.handler = nxt_http_var_host,
+ .cacheable = 1,
}, {
.name = nxt_string("remote_addr"),
.handler = nxt_http_var_remote_addr,
+ .cacheable = 1,
}, {
.name = nxt_string("time_local"),
.handler = nxt_http_var_time_local,
+ .cacheable = 1,
}, {
.name = nxt_string("request_line"),
.handler = nxt_http_var_request_line,
+ .cacheable = 1,
}, {
.name = nxt_string("status"),
.handler = nxt_http_var_status,
+ .cacheable = 1,
}, {
.name = nxt_string("body_bytes_sent"),
.handler = nxt_http_var_body_bytes_sent,
+ .cacheable = 1,
}, {
.name = nxt_string("header_referer"),
.handler = nxt_http_var_referer,
+ .cacheable = 1,
}, {
.name = nxt_string("header_user_agent"),
.handler = nxt_http_var_user_agent,
+ .cacheable = 1,
}, {
.name = nxt_string("arg"),
.handler = nxt_http_var_arg,
.field_hash = nxt_http_argument_hash,
+ .cacheable = 1,
}, {
.name = nxt_string("header"),
.handler = nxt_http_var_header,
.field_hash = nxt_http_header_hash,
+ .cacheable = 1,
}, {
.name = nxt_string("cookie"),
.handler = nxt_http_var_cookie,
.field_hash = nxt_http_cookie_hash,
+ .cacheable = 1,
},
};