summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_compress_gzip.c
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@nginx.com>2023-08-24 14:09:18 +0200
committerAlejandro Colomar <alx@nginx.com>2023-09-05 02:12:28 +0200
commit334804209068a4450d22097170fef5c3987c0fa3 (patch)
tree5088a9960b3bdbffa7f1438e57598a3b7cd37003 /src/nxt_http_compress_gzip.c
parent3dfab08abc813c9cd2b5e9cb910ae5c557117c93 (diff)
downloadunit-334804209068a4450d22097170fef5c3987c0fa3.tar.gz
unit-334804209068a4450d22097170fef5c3987c0fa3.tar.bz2
HTTP: compress: added configurable threshold for Content-Length.
With this, short responses, that is, responses with a body of up to content_length_threshold bytes, won't be compressed. The default value is 20, as in NGINX. Signed-off-by: Alejandro Colomar <alx@nginx.com>
Diffstat (limited to 'src/nxt_http_compress_gzip.c')
-rw-r--r--src/nxt_http_compress_gzip.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/nxt_http_compress_gzip.c b/src/nxt_http_compress_gzip.c
index db675ecf..2d0d65ae 100644
--- a/src/nxt_http_compress_gzip.c
+++ b/src/nxt_http_compress_gzip.c
@@ -54,18 +54,15 @@ nxt_int_t
nxt_http_compress_gzip(nxt_task_t *task, nxt_http_request_t *r,
nxt_http_compress_conf_t *conf)
{
+ size_t clen;
nxt_int_t ret;
nxt_http_compress_gzip_ctx_t *ctx;
static nxt_str_t ce = nxt_string("Content-Encoding");
static nxt_str_t gzip = nxt_string("gzip");
- if (r->body_handler == NULL
- || r->resp.content_length_n == 0
- || (r->resp.content_length != NULL
- && r->resp.content_length->value_length == 1
- && r->resp.content_length->value[0] == '0'))
- {
+ clen = nxt_http_compress_resp_content_length(&r->resp);
+ if (clen < nxt_max(1u, conf->min_len) || r->body_handler == NULL) {
return NXT_OK;
}