summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nxt_conf_validation.c3
-rw-r--r--src/nxt_http_compress.c10
-rw-r--r--src/nxt_http_compress.h4
-rw-r--r--src/nxt_http_compress_gzip.c8
4 files changed, 23 insertions, 2 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index 0e1f7340..4943c603 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -1158,6 +1158,9 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_compress_members[] = {
{
.name = nxt_string("encoding"),
.type = NXT_CONF_VLDT_STRING,
+ }, {
+ .name = nxt_string("level"),
+ .type = NXT_CONF_VLDT_INTEGER,
},
NXT_CONF_VLDT_END
diff --git a/src/nxt_http_compress.c b/src/nxt_http_compress.c
index e27dd278..f78a16ed 100644
--- a/src/nxt_http_compress.c
+++ b/src/nxt_http_compress.c
@@ -23,12 +23,20 @@
#include "nxt_types.h"
+#define NXT_DEFAULT_COMPRESSION (-1)
+
+
static nxt_conf_map_t nxt_http_compress_conf[] = {
{
nxt_string("encoding"),
NXT_CONF_MAP_STR,
offsetof(nxt_http_compress_conf_t, encoding),
},
+ {
+ nxt_string("level"),
+ NXT_CONF_MAP_INT8,
+ offsetof(nxt_http_compress_conf_t, level),
+ },
};
@@ -47,6 +55,8 @@ nxt_http_compress_init(nxt_router_conf_t *rtcf, nxt_http_action_t *action,
return NXT_ERROR;
}
+ conf->level = NXT_DEFAULT_COMPRESSION;
+
ret = nxt_conf_map_object(mp, acf->compress, nxt_http_compress_conf,
nxt_nitems(nxt_http_compress_conf), conf);
if (nxt_slow_path(ret == NXT_ERROR)) {
diff --git a/src/nxt_http_compress.h b/src/nxt_http_compress.h
index 57bebd1c..19075025 100644
--- a/src/nxt_http_compress.h
+++ b/src/nxt_http_compress.h
@@ -9,6 +9,8 @@
#include "nxt_router.h"
+#include <stdint.h>
+
#include "nxt_http.h"
#include "nxt_main.h"
#include "nxt_router.h"
@@ -22,6 +24,8 @@ struct nxt_http_compress_conf_s {
nxt_int_t (*handler)(nxt_task_t *task,
nxt_http_request_t *r,
nxt_http_compress_conf_t *conf);
+
+ int8_t level;
};
diff --git a/src/nxt_http_compress_gzip.c b/src/nxt_http_compress_gzip.c
index 75ed9155..169b463d 100644
--- a/src/nxt_http_compress_gzip.c
+++ b/src/nxt_http_compress_gzip.c
@@ -7,6 +7,7 @@
#include "nxt_http_compress_gzip.h"
#include <stddef.h>
+#include <stdint.h>
#include <zlib.h>
@@ -32,6 +33,8 @@ struct nxt_http_compress_gzip_ctx_s {
nxt_http_request_t *r;
nxt_buf_t *b;
+ int8_t level;
+
z_stream z;
};
@@ -97,14 +100,15 @@ nxt_http_compress_gzip_ctx(nxt_task_t *task, nxt_http_request_t *r,
return NULL;
}
+ ctx->level = conf->level;
ctx->r = r;
z = &ctx->z;
z->zalloc = NULL;
z->zfree = NULL;
z->opaque = NULL;
- ret = deflateInit2(z, Z_DEFAULT_COMPRESSION, Z_DEFLATED, MAX_WBITS + 16,
- MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
+ ret = deflateInit2(z, ctx->level, Z_DEFLATED, MAX_WBITS + 16, MAX_MEM_LEVEL,
+ Z_DEFAULT_STRATEGY);
if (nxt_slow_path(ret != 0)) {
return NULL;
}