Commit Graph

18 Commits

Author SHA1 Message Date
Zhidao HONG
63507c499e Var: Make nxt_var_cache_value() more general
This commit enhances nxt_var_cache_value() to enable variable access
using string names, complementing the existing reference index method.
The modification ensures future compatibility with njs variable access.
2024-02-20 06:09:23 +08:00
Zhidao HONG
01fd121c4e Var: Refactored nxt_http_unknown_var_ref() 2024-02-20 06:09:23 +08:00
Zhidao HONG
62894ae77b Var: Refactored nxt_var_ref_get() 2024-02-20 06:09:23 +08:00
Zhidao HONG
c61ccec7b4 Variables refactoring.
This commit is to reimplement the variables with an unknown field
such as $header_{name} to make the parsing more generic,
it's a preparation for supporting response header variables.
2023-06-19 16:29:22 +08:00
Zhidao HONG
a378f6aa31 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.
2023-05-25 00:27:55 +08:00
Zhidao HONG
4735931ace Var: separating nxt_tstr_t from nxt_var_t.
It's for the introduction of njs support.
For each option that supports native variable and JS template literals introduced next,
it's unified as template string.

No functional changes.
2022-11-20 23:15:01 +08:00
Zhidao HONG
3711632c00 Var: improved variable parsing with empty names.
Unit parsed the case of "$uri$$host" into unknown variables.
This commit makes it invalid variable instead.
2022-11-20 23:11:41 +08:00
Alejandro Colomar
ebf02266a2 Removed the unsafe nxt_memchr() wrapper for memchr(3).
The casts are unnecessary, since memchr(3)'s argument is 'const void *'.
It might have been necessary in the times of K&R, where 'void *' didn't
exist.  Nowadays, it's unnecessary, and _very_ unsafe, since casts can
hide all classes of bugs by silencing most compiler warnings.

The changes from nxt_memchr() to memchr(3) were scripted:

$ find src/ -type f \
  | grep '\.[ch]$' \
  | xargs sed -i 's/nxt_memchr/memchr/'

Reviewed-by: Andrew Clayton <a.clayton@nginx.com>
Signed-off-by: Alejandro Colomar <alx@nginx.com>
2022-11-04 00:30:50 +01:00
Zhidao HONG
3f8cf62c03 Log: customizable access log format. 2022-07-28 11:05:04 +08:00
Zhidao HONG
45b89e3257 Var: dynamic variables support.
This commit adds the variables $arg_NAME, $header_NAME, and $cookie_NAME.
2022-07-14 04:32:49 +08:00
Zhidao HONG
7b80186f09 Var: optimization to get rid of nxt_var_cache_find().
No functional changes.
2022-07-14 04:31:36 +08:00
Zhidao HONG
6a8081d71e Var: relocated nxt_var_is_const() and nxt_var_raw().
No functional changes.
2022-06-15 14:27:50 +08:00
Zhidao HONG
0d2d40e231 Summary: Var: removing all async stuff.
No functional changes.
2022-06-02 09:36:35 +08:00
Zhidao HONG
a6a884ebdb Fixed debug message broken in 45b25ffb2e8c. 2021-12-03 12:08:54 +08:00
Zhidao HONG
37144d6849 Static: variables in the "chroot" option. 2021-09-28 23:08:26 +08:00
Zhidao HONG
a336928e10 Router: refactored variable pass.
Since the "pass" option supports both strings and variables, a generic
nxt_var_t structure can be used in the configuration phase, and the "name"
field in actions is redundant.

No functional changes.
2021-09-07 21:13:44 +08:00
Zhidao HONG
9c1894bf77 Var: keeping raw variable string for debug. 2021-09-06 19:27:45 +08:00
Valentin Bartenev
93146616cf Basic variables support. 2020-08-13 02:46:54 +03:00