summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_compress_gzip.c
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@nginx.com>2023-08-23 17:23:49 +0200
committerAlejandro Colomar <alx@nginx.com>2023-09-04 03:40:32 +0200
commit7ecdc3d190e449f04ac69d62f437399851035028 (patch)
tree8294f5d8c857ddd5b442240d365799b8b3730bba /src/nxt_http_compress_gzip.c
parent00801288b07d9d7c9557667b8020bab61375ca1c (diff)
downloadunit-7ecdc3d190e449f04ac69d62f437399851035028.tar.gz
unit-7ecdc3d190e449f04ac69d62f437399851035028.tar.bz2
HTTP: compress: added configurable "level" of compression.
Diffstat (limited to '')
-rw-r--r--src/nxt_http_compress_gzip.c8
1 files changed, 6 insertions, 2 deletions
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;
}