Skip to content

Commit 2d7a846

Browse files
committed
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
1 parent a625a0b commit 2d7a846

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/nxt_conf_validation.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2572,6 +2572,7 @@ static nxt_int_t
25722572
nxt_conf_vldt_response_header(nxt_conf_validation_t *vldt, nxt_str_t *name,
25732573
nxt_conf_value_t *value)
25742574
{
2575+
nxt_str_t str;
25752576
nxt_uint_t type;
25762577

25772578
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,
25882589

25892590
type = nxt_conf_type(value);
25902591

2591-
if (type == NXT_CONF_STRING || type == NXT_CONF_NULL) {
2592+
if (type == NXT_CONF_NULL) {
2593+
return NXT_OK;
2594+
}
2595+
2596+
if (type == NXT_CONF_STRING) {
2597+
nxt_conf_get_string(value, &str);
2598+
2599+
if (nxt_is_tstr(&str)) {
2600+
return nxt_conf_vldt_var(vldt, name, &str);
2601+
}
2602+
25922603
return NXT_OK;
25932604
}
25942605

0 commit comments

Comments
 (0)