summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_tstr.c
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2023-06-19 16:29:22 +0800
committerZhidao HONG <z.hong@f5.com>2023-06-19 16:29:22 +0800
commitc61ccec7b4926476b2188092e25990e433332688 (patch)
tree191c14c58ae229e6060644eafce25a82040a2bbc /src/nxt_tstr.c
parent18d3637e4bffd5fff09091a536dca3fdecc931d7 (diff)
downloadunit-c61ccec7b4926476b2188092e25990e433332688.tar.gz
unit-c61ccec7b4926476b2188092e25990e433332688.tar.bz2
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.
Diffstat (limited to '')
-rw-r--r--src/nxt_tstr.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nxt_tstr.c b/src/nxt_tstr.c
index 0e084bb4..edf6860a 100644
--- a/src/nxt_tstr.c
+++ b/src/nxt_tstr.c
@@ -64,8 +64,8 @@ nxt_tstr_state_new(nxt_mp_t *mp, nxt_bool_t test)
state->pool = mp;
state->test = test;
- state->var_fields = nxt_array_create(mp, 4, sizeof(nxt_var_field_t));
- if (nxt_slow_path(state->var_fields == NULL)) {
+ state->var_refs = nxt_array_create(mp, 4, sizeof(nxt_var_ref_t));
+ if (nxt_slow_path(state->var_refs == NULL)) {
return NULL;
}
@@ -133,8 +133,7 @@ nxt_tstr_compile(nxt_tstr_state_t *state, nxt_str_t *str,
if (p != NULL) {
tstr->type = NXT_TSTR_VAR;
- tstr->u.var = nxt_var_compile(&tstr->str, state->pool,
- state->var_fields);
+ tstr->u.var = nxt_var_compile(state, &tstr->str);
if (nxt_slow_path(tstr->u.var == NULL)) {
return NULL;
}
@@ -168,7 +167,7 @@ nxt_tstr_test(nxt_tstr_state_t *state, nxt_str_t *str, u_char *error)
p = memchr(str->start, '$', str->length);
if (p != NULL) {
- return nxt_var_test(str, state->var_fields, error);
+ return nxt_var_test(state, str, error);
}
}
@@ -263,8 +262,9 @@ nxt_tstr_query(nxt_task_t *task, nxt_tstr_query_t *query, nxt_tstr_t *tstr,
}
if (tstr->type == NXT_TSTR_VAR) {
- ret = nxt_var_interpreter(task, &query->cache->var, tstr->u.var, val,
- query->ctx, tstr->flags & NXT_TSTR_LOGGING);
+ ret = nxt_var_interpreter(task, query->state, &query->cache->var,
+ tstr->u.var, val, query->ctx,
+ tstr->flags & NXT_TSTR_LOGGING);
if (nxt_slow_path(ret != NXT_OK)) {
query->failed = 1;