summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2023-08-09 14:37:16 +0800
committerZhidao HONG <z.hong@f5.com>2023-08-09 14:37:16 +0800
commita28bef097cd63da3bbb375ef0283e65be41a88ff (patch)
tree8553e74c050a9747bdba928cbaec82ee6d15cb5d /src/nxt_conf_validation.c
parent9f04d6db630a22658581cbe7a9d28ecdb13d8de9 (diff)
downloadunit-a28bef097cd63da3bbb375ef0283e65be41a88ff.tar.gz
unit-a28bef097cd63da3bbb375ef0283e65be41a88ff.tar.bz2
HTTP: controlling response headers support.
Diffstat (limited to 'src/nxt_conf_validation.c')
-rw-r--r--src/nxt_conf_validation.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index 8c75a9fe..09f5598e 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -167,6 +167,8 @@ static nxt_int_t nxt_conf_vldt_match_addrs(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_match_addr(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value);
+static nxt_int_t nxt_conf_vldt_response_header(nxt_conf_validation_t *vldt,
+ nxt_str_t *name, nxt_conf_value_t *value);
static nxt_int_t nxt_conf_vldt_app_name(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_forwarded(nxt_conf_validation_t *vldt,
@@ -688,6 +690,12 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_action_common_members[] = {
.name = nxt_string("rewrite"),
.type = NXT_CONF_VLDT_STRING,
},
+ {
+ .name = nxt_string("response_headers"),
+ .type = NXT_CONF_VLDT_OBJECT,
+ .validator = nxt_conf_vldt_object_iterator,
+ .u.object = nxt_conf_vldt_response_header,
+ },
NXT_CONF_VLDT_END
};
@@ -2448,6 +2456,35 @@ nxt_conf_vldt_object_conf_commands(nxt_conf_validation_t *vldt,
static nxt_int_t
+nxt_conf_vldt_response_header(nxt_conf_validation_t *vldt, nxt_str_t *name,
+ nxt_conf_value_t *value)
+{
+ nxt_uint_t type;
+
+ static nxt_str_t content_length = nxt_string("Content-Length");
+
+ if (name->length == 0) {
+ return nxt_conf_vldt_error(vldt, "The response header name "
+ "must not be empty.");
+ }
+
+ if (nxt_strstr_eq(name, &content_length)) {
+ return nxt_conf_vldt_error(vldt, "The \"Content-Length\" response "
+ "header value is not supported");
+ }
+
+ type = nxt_conf_type(value);
+
+ if (type == NXT_CONF_STRING || type == NXT_CONF_NULL) {
+ return NXT_OK;
+ }
+
+ return nxt_conf_vldt_error(vldt, "The \"%V\" response header value "
+ "must either be a string or a null", name);
+}
+
+
+static nxt_int_t
nxt_conf_vldt_app_name(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
void *data)
{