|
13 | 13 | #include <nxt_http.h>
|
14 | 14 | #include <nxt_sockaddr.h>
|
15 | 15 | #include <nxt_http_route_addr.h>
|
| 16 | +#include <nxt_http_compression.h> |
16 | 17 | #include <nxt_regex.h>
|
17 | 18 |
|
18 | 19 |
|
@@ -140,6 +141,12 @@ static nxt_int_t nxt_conf_vldt_threads(nxt_conf_validation_t *vldt,
|
140 | 141 | nxt_conf_value_t *value, void *data);
|
141 | 142 | static nxt_int_t nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t *vldt,
|
142 | 143 | nxt_conf_value_t *value, void *data);
|
| 144 | +static nxt_int_t nxt_conf_vldt_compressors(nxt_conf_validation_t *vldt, |
| 145 | + nxt_conf_value_t *value, void *data); |
| 146 | +static nxt_int_t nxt_conf_vldt_compression(nxt_conf_validation_t *vldt, |
| 147 | + nxt_conf_value_t *value); |
| 148 | +static nxt_int_t nxt_conf_vldt_compression_encoding(nxt_conf_validation_t *vldt, |
| 149 | + nxt_conf_value_t *value, void *data); |
143 | 150 | static nxt_int_t nxt_conf_vldt_routes(nxt_conf_validation_t *vldt,
|
144 | 151 | nxt_conf_value_t *value, void *data);
|
145 | 152 | static nxt_int_t nxt_conf_vldt_routes_member(nxt_conf_validation_t *vldt,
|
@@ -263,6 +270,8 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_otel_members[];
|
263 | 270 | #endif
|
264 | 271 | static nxt_conf_vldt_object_t nxt_conf_vldt_websocket_members[];
|
265 | 272 | static nxt_conf_vldt_object_t nxt_conf_vldt_static_members[];
|
| 273 | +static nxt_conf_vldt_object_t nxt_conf_vldt_compression_members[]; |
| 274 | +static nxt_conf_vldt_object_t nxt_conf_vldt_compressor_members[]; |
266 | 275 | static nxt_conf_vldt_object_t nxt_conf_vldt_forwarded_members[];
|
267 | 276 | static nxt_conf_vldt_object_t nxt_conf_vldt_client_ip_members[];
|
268 | 277 | #if (NXT_TLS)
|
@@ -403,6 +412,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_http_members[] = {
|
403 | 412 | }, {
|
404 | 413 | .name = nxt_string("chunked_transform"),
|
405 | 414 | .type = NXT_CONF_VLDT_BOOLEAN,
|
| 415 | + }, { |
| 416 | + .name = nxt_string("compression"), |
| 417 | + .type = NXT_CONF_VLDT_OBJECT, |
| 418 | + .validator = nxt_conf_vldt_object, |
| 419 | + .u.members = nxt_conf_vldt_compression_members, |
406 | 420 | },
|
407 | 421 |
|
408 | 422 | NXT_CONF_VLDT_END
|
@@ -465,6 +479,39 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_static_members[] = {
|
465 | 479 | };
|
466 | 480 |
|
467 | 481 |
|
| 482 | +static nxt_conf_vldt_object_t nxt_conf_vldt_compression_members[] = { |
| 483 | + { |
| 484 | + .name = nxt_string("types"), |
| 485 | + .type = NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY, |
| 486 | + .validator = nxt_conf_vldt_match_patterns, |
| 487 | + }, { |
| 488 | + .name = nxt_string("compressors"), |
| 489 | + .type = NXT_CONF_VLDT_OBJECT | NXT_CONF_VLDT_ARRAY, |
| 490 | + .validator = nxt_conf_vldt_compressors, |
| 491 | + }, |
| 492 | + |
| 493 | + NXT_CONF_VLDT_END |
| 494 | +}; |
| 495 | + |
| 496 | + |
| 497 | +static nxt_conf_vldt_object_t nxt_conf_vldt_compressor_members[] = { |
| 498 | + { |
| 499 | + .name = nxt_string("encoding"), |
| 500 | + .type = NXT_CONF_VLDT_STRING, |
| 501 | + .flags = NXT_CONF_VLDT_REQUIRED, |
| 502 | + .validator = nxt_conf_vldt_compression_encoding, |
| 503 | + }, { |
| 504 | + .name = nxt_string("level"), |
| 505 | + .type = NXT_CONF_VLDT_INTEGER, |
| 506 | + }, { |
| 507 | + .name = nxt_string("min_length"), |
| 508 | + .type = NXT_CONF_VLDT_INTEGER, |
| 509 | + }, |
| 510 | + |
| 511 | + NXT_CONF_VLDT_END |
| 512 | +}; |
| 513 | + |
| 514 | + |
468 | 515 | static nxt_conf_vldt_object_t nxt_conf_vldt_listener_members[] = {
|
469 | 516 | {
|
470 | 517 | .name = nxt_string("pass"),
|
@@ -2270,6 +2317,52 @@ nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t *vldt,
|
2270 | 2317 | }
|
2271 | 2318 |
|
2272 | 2319 |
|
| 2320 | +static nxt_int_t |
| 2321 | +nxt_conf_vldt_compressors(nxt_conf_validation_t *vldt, nxt_conf_value_t *value, |
| 2322 | + void *data) |
| 2323 | +{ |
| 2324 | + if (nxt_conf_type(value) == NXT_CONF_ARRAY) { |
| 2325 | + return nxt_conf_vldt_array_iterator(vldt, value, |
| 2326 | + &nxt_conf_vldt_compression); |
| 2327 | + } |
| 2328 | + |
| 2329 | + /* NXT_CONF_OBJECT */ |
| 2330 | + |
| 2331 | + return nxt_conf_vldt_object_iterator(vldt, value, |
| 2332 | + &nxt_conf_vldt_compressor_members); |
| 2333 | +} |
| 2334 | + |
| 2335 | + |
| 2336 | +static nxt_int_t |
| 2337 | +nxt_conf_vldt_compression(nxt_conf_validation_t *vldt, nxt_conf_value_t *value) |
| 2338 | +{ |
| 2339 | + if (nxt_conf_type(value) != NXT_CONF_OBJECT) { |
| 2340 | + return nxt_conf_vldt_error(vldt, |
| 2341 | + "The \"compressors\" array must contain " |
| 2342 | + "only object values."); |
| 2343 | + } |
| 2344 | + |
| 2345 | + return nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_compressor_members); |
| 2346 | +} |
| 2347 | + |
| 2348 | + |
| 2349 | +static nxt_int_t |
| 2350 | +nxt_conf_vldt_compression_encoding(nxt_conf_validation_t *vldt, |
| 2351 | + nxt_conf_value_t *value, void *data) |
| 2352 | +{ |
| 2353 | + nxt_str_t token; |
| 2354 | + |
| 2355 | + nxt_conf_get_string(value, &token); |
| 2356 | + |
| 2357 | + if (nxt_http_comp_compressor_is_valid(&token)) { |
| 2358 | + return NXT_OK; |
| 2359 | + } |
| 2360 | + |
| 2361 | + return nxt_conf_vldt_error(vldt, "\"%V\" is not a supported compressor.", |
| 2362 | + &token); |
| 2363 | +} |
| 2364 | + |
| 2365 | + |
2273 | 2366 | static nxt_int_t
|
2274 | 2367 | nxt_conf_vldt_routes(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
|
2275 | 2368 | void *data)
|
|
0 commit comments