diff options
author | Zhidao HONG <z.hong@f5.com> | 2024-03-18 15:16:17 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2024-04-10 23:21:21 +0800 |
commit | 2d7a84684312fc1c46043fa10af0ea336e73f11d (patch) | |
tree | 0164cb692c425dd7e87770410a7722424527da81 /src/nxt_conf_validation.c | |
parent | a625a0b1f0d822b3224b7b29565fe9733b634afd (diff) | |
download | unit-2d7a84684312fc1c46043fa10af0ea336e73f11d.tar.gz unit-2d7a84684312fc1c46043fa10af0ea336e73f11d.tar.bz2 |
HTTP: Added variable validation to the response_headers option
This is to improve error messages for response headers configuration.
Take the configuration as an example:
{
"response_headers": {
"a": "$b"
}
}
Previously, when applying it the user would see this error message:
failed to apply previous configuration
After this change, the user will see this improved error message:
the previous configuration is invalid: Unknown variable "b" in the "a" value
Diffstat (limited to '')
-rw-r--r-- | src/nxt_conf_validation.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c index 2099f887..8f802fb7 100644 --- a/src/nxt_conf_validation.c +++ b/src/nxt_conf_validation.c @@ -2572,6 +2572,7 @@ static nxt_int_t nxt_conf_vldt_response_header(nxt_conf_validation_t *vldt, nxt_str_t *name, nxt_conf_value_t *value) { + nxt_str_t str; nxt_uint_t type; static nxt_str_t content_length = nxt_string("Content-Length"); @@ -2588,7 +2589,17 @@ nxt_conf_vldt_response_header(nxt_conf_validation_t *vldt, nxt_str_t *name, type = nxt_conf_type(value); - if (type == NXT_CONF_STRING || type == NXT_CONF_NULL) { + if (type == NXT_CONF_NULL) { + return NXT_OK; + } + + if (type == NXT_CONF_STRING) { + nxt_conf_get_string(value, &str); + + if (nxt_is_tstr(&str)) { + return nxt_conf_vldt_var(vldt, name, &str); + } + return NXT_OK; } |