summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2024-06-11 00:24:28 +0100
committerAndrew Clayton <a.clayton@nginx.com>2024-06-19 16:15:04 +0100
commit4071de5797da0a104b4983fc1ad393d3744b6128 (patch)
tree003803a861f2609cfae58db412e1c3d7ee6dc8f9 /src/nxt_conf_validation.c
parentea5c41b8056997ed40138020272b5159271f1b87 (diff)
downloadunit-compr.tar.gz
unit-compr.tar.bz2
[WIP] HTTP Compression Supportcompr
Diffstat (limited to 'src/nxt_conf_validation.c')
-rw-r--r--src/nxt_conf_validation.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index 4aaa1b9a..e3a75a29 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -13,6 +13,7 @@
#include <nxt_http.h>
#include <nxt_sockaddr.h>
#include <nxt_http_route_addr.h>
+#include <nxt_http_compression.h>
#include <nxt_regex.h>
@@ -138,6 +139,14 @@ static nxt_int_t nxt_conf_vldt_threads(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
+static nxt_int_t nxt_conf_vldt_compressors(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data);
+static nxt_int_t nxt_conf_vldt_compression(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value);
+static nxt_int_t nxt_conf_vldt_compression_encoding(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data);
+static nxt_int_t nxt_conf_vldt_compression_level(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_routes(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_routes_member(nxt_conf_validation_t *vldt,
@@ -242,6 +251,8 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_setting_members[];
static nxt_conf_vldt_object_t nxt_conf_vldt_http_members[];
static nxt_conf_vldt_object_t nxt_conf_vldt_websocket_members[];
static nxt_conf_vldt_object_t nxt_conf_vldt_static_members[];
+static nxt_conf_vldt_object_t nxt_conf_vldt_compression_members[];
+static nxt_conf_vldt_object_t nxt_conf_vldt_compressor_members[];
static nxt_conf_vldt_object_t nxt_conf_vldt_forwarded_members[];
static nxt_conf_vldt_object_t nxt_conf_vldt_client_ip_members[];
#if (NXT_TLS)
@@ -368,6 +379,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_http_members[] = {
}, {
.name = nxt_string("server_version"),
.type = NXT_CONF_VLDT_BOOLEAN,
+ }, {
+ .name = nxt_string("compression"),
+ .type = NXT_CONF_VLDT_OBJECT,
+ .validator = nxt_conf_vldt_object,
+ .u.members = nxt_conf_vldt_compression_members,
},
NXT_CONF_VLDT_END
@@ -402,6 +418,40 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_static_members[] = {
};
+static nxt_conf_vldt_object_t nxt_conf_vldt_compression_members[] = {
+ {
+ .name = nxt_string("types"),
+ .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
+ .validator = nxt_conf_vldt_match_patterns,
+ }, {
+ .name = nxt_string("compressors"),
+ .type = NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY,
+ .validator = nxt_conf_vldt_compressors,
+ },
+
+ NXT_CONF_VLDT_END
+};
+
+
+static nxt_conf_vldt_object_t nxt_conf_vldt_compressor_members[] = {
+ {
+ .name = nxt_string("encoding"),
+ .type = NXT_CONF_VLDT_STRING,
+ .flags = NXT_CONF_VLDT_REQUIRED,
+ .validator = nxt_conf_vldt_compression_encoding,
+ }, {
+ .name = nxt_string("level"),
+ .type = NXT_CONF_VLDT_INTEGER,
+ .validator = nxt_conf_vldt_compression_level,
+ }, {
+ .name = nxt_string("min_length"),
+ .type = NXT_CONF_VLDT_INTEGER,
+ },
+
+ NXT_CONF_VLDT_END
+};
+
+
static nxt_conf_vldt_object_t nxt_conf_vldt_listener_members[] = {
{
.name = nxt_string("pass"),
@@ -2113,6 +2163,62 @@ nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t *vldt,
static nxt_int_t
+nxt_conf_vldt_compressors(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
+ void *data)
+{
+ if (nxt_conf_type(value) == NXT_CONF_ARRAY) {
+ return nxt_conf_vldt_array_iterator(vldt, value,
+ &nxt_conf_vldt_compression);
+ }
+
+ /* NXT_CONF_OBJECT */
+
+ return nxt_conf_vldt_object_iterator(vldt, value,
+ &nxt_conf_vldt_compressor_members);
+}
+
+
+static nxt_int_t
+nxt_conf_vldt_compression(nxt_conf_validation_t *vldt, nxt_conf_value_t *value)
+{
+ if (nxt_conf_type(value) != NXT_CONF_OBJECT) {
+ return nxt_conf_vldt_error(vldt,
+ "The \"compressors\" array must contain "
+ "only object values.");
+ }
+
+ return nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_compressor_members);
+}
+
+
+static nxt_int_t
+nxt_conf_vldt_compression_encoding(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data)
+{
+ nxt_str_t token;
+
+ nxt_conf_get_string(value, &token);
+
+ if (nxt_http_comp_compressor_is_valid(&token)) {
+ return NXT_OK;
+ }
+
+ return nxt_conf_vldt_error(vldt, "\"%V\" is not a supported compressor.",
+ &token);
+}
+
+
+static nxt_int_t
+nxt_conf_vldt_compression_level(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data)
+{
+ /* XXX Fill me in */
+
+ return NXT_OK;
+}
+
+
+static nxt_int_t
nxt_conf_vldt_routes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
void *data)
{