diff options
author | Alejandro Colomar <alx@nginx.com> | 2023-07-21 13:58:37 +0200 |
---|---|---|
committer | Alejandro Colomar <alx@nginx.com> | 2023-09-04 03:40:33 +0200 |
commit | 39db8691fe40adcfdb827c194636b87391c7c416 (patch) | |
tree | c06c80848d8fb034c41c330235cb8c91a160e2d0 | |
parent | 7ecdc3d190e449f04ac69d62f437399851035028 (diff) | |
download | unit-39db8691fe40adcfdb827c194636b87391c7c416.tar.gz unit-39db8691fe40adcfdb827c194636b87391c7c416.tar.bz2 |
Auto: zlib: added --no-zlib.
Related to:
HTTP: compress: gzip
Signed-off-by: Alejandro Colomar <alx@nginx.com>
-rw-r--r-- | auto/options | 4 | ||||
-rw-r--r-- | auto/summary | 1 | ||||
-rw-r--r-- | auto/zlib | 39 | ||||
-rw-r--r-- | src/nxt_http_compress.c | 2 | ||||
-rw-r--r-- | src/nxt_http_compress_gzip.c | 14 | ||||
-rw-r--r-- | src/nxt_http_compress_gzip.h | 9 |
6 files changed, 52 insertions, 17 deletions
diff --git a/auto/options b/auto/options index 0550c699..ef0459f3 100644 --- a/auto/options +++ b/auto/options @@ -20,6 +20,8 @@ NXT_PCRE_LIB= NXT_REGEX=YES NXT_TRY_PCRE2=YES +NXT_ZLIB=YES + NXT_TLS=NO NXT_OPENSSL=NO NXT_GNUTLS=NO @@ -104,6 +106,8 @@ do --no-regex) NXT_REGEX=NO ;; --no-pcre2) NXT_TRY_PCRE2=NO ;; + --no-zlib) NXT_ZLIB=NO ;; + --openssl) NXT_OPENSSL=YES ;; --gnutls) NXT_GNUTLS=YES ;; --cyassl) NXT_CYASSL=YES ;; diff --git a/auto/summary b/auto/summary index 3aa41669..0e87b88a 100644 --- a/auto/summary +++ b/auto/summary @@ -29,6 +29,7 @@ Unit configuration summary: Unix domain sockets support: $NXT_UNIX_DOMAIN TLS support: ............... $NXT_OPENSSL Regex support: ............. $NXT_REGEX + zlib support: .............. $NXT_ZLIB NJS support: ............... $NXT_NJS process isolation: ......... $NXT_ISOLATION @@ -3,21 +3,32 @@ # Copyright (C) NGINX, Inc. -NXT_ZLIB_CFLAGS="$(pkgconf --cflags-only-I zlib 2>/dev/null || echo "")" -NXT_ZLIB_LIBS="$(pkgconf --libs zlib 2>/dev/null || echo "-lz")" +NXT_HAVE_ZLIB=no +NXT_ZLIB_CFLAGS= +NXT_ZLIB_LIBS= -nxt_feature="zlib" -nxt_feature_name=NXT_HAVE_ZLIB -nxt_feature_run=no -nxt_feature_incs=$NXT_ZLIB_CFLAGS -nxt_feature_libs=$NXT_ZLIB_LIBS -nxt_feature_test="#include <stdio.h> +if [ $NXT_ZLIB = YES ]; then - #include <zlib.h> + NXT_ZLIB_CFLAGS="$(pkgconf --cflags-only-I zlib 2>/dev/null || echo "")" + NXT_ZLIB_LIBS="$(pkgconf --libs zlib 2>/dev/null || echo "-lz")" - int main(void) { - puts(zlibVersion()); - return 0; - }" -. auto/feature + nxt_feature="zlib" + nxt_feature_name=NXT_HAVE_ZLIB + nxt_feature_run=no + nxt_feature_incs=$NXT_ZLIB_CFLAGS + nxt_feature_libs=$NXT_ZLIB_LIBS + nxt_feature_test="#include <stdio.h> + + #include <zlib.h> + + int main(void) { + puts(zlibVersion()); + return 0; + }" + . auto/feature + + if [ $nxt_found = yes ]; then + NXT_HAVE_ZLIB=YES + fi +fi diff --git a/src/nxt_http_compress.c b/src/nxt_http_compress.c index f78a16ed..55e20e3a 100644 --- a/src/nxt_http_compress.c +++ b/src/nxt_http_compress.c @@ -63,7 +63,7 @@ nxt_http_compress_init(nxt_router_conf_t *rtcf, nxt_http_action_t *action, return NXT_ERROR; } - if (nxt_str_eq(&conf->encoding, "gzip", strlen("gzip"))) { + if (NXT_WITH_ZLIB && nxt_str_eq(&conf->encoding, "gzip", strlen("gzip"))) { conf->handler = nxt_http_compress_gzip; } else { diff --git a/src/nxt_http_compress_gzip.c b/src/nxt_http_compress_gzip.c index 169b463d..db675ecf 100644 --- a/src/nxt_http_compress_gzip.c +++ b/src/nxt_http_compress_gzip.c @@ -9,8 +9,6 @@ #include <stddef.h> #include <stdint.h> -#include <zlib.h> - #include <nxt_unit_cdefs.h> #include "nxt_buf.h" @@ -25,6 +23,10 @@ #include "nxt_string.h" #include "nxt_types.h" +#if (NXT_WITH_ZLIB || __has_include(<zlib.h>)) +#include <zlib.h> +#endif + typedef struct nxt_http_compress_gzip_ctx_s nxt_http_compress_gzip_ctx_t; @@ -35,7 +37,9 @@ struct nxt_http_compress_gzip_ctx_s { int8_t level; +#if (NXT_WITH_ZLIB) z_stream z; +#endif }; @@ -91,6 +95,9 @@ static nxt_http_compress_gzip_ctx_t * nxt_http_compress_gzip_ctx(nxt_task_t *task, nxt_http_request_t *r, nxt_http_compress_conf_t *conf) { +#if (!NXT_WITH_ZLIB) + return NULL; +#else int ret; z_stream *z; nxt_http_compress_gzip_ctx_t *ctx; @@ -114,12 +121,14 @@ nxt_http_compress_gzip_ctx(nxt_task_t *task, nxt_http_request_t *r, } return ctx; +#endif } static void nxt_http_compress_gzip_filter(nxt_task_t *task, void *obj, void *data) { +#if (NXT_WITH_ZLIB) int ret; ssize_t size; z_stream *z; @@ -180,4 +189,5 @@ fail: } return; +#endif } diff --git a/src/nxt_http_compress_gzip.h b/src/nxt_http_compress_gzip.h index 15facc69..e0c2dee2 100644 --- a/src/nxt_http_compress_gzip.h +++ b/src/nxt_http_compress_gzip.h @@ -7,6 +7,8 @@ #define NXT_HTTP_COMPRESS_GZIP_H_INCLUDED_ +#include "nxt_auto_config.h" + #include "nxt_router.h" #include "nxt_http.h" @@ -14,6 +16,13 @@ #include "nxt_types.h" +#if defined(NXT_HAVE_ZLIB) +#define NXT_WITH_ZLIB 1 +#else +#define NXT_WITH_ZLIB 0 +#endif + + nxt_int_t nxt_http_compress_gzip(nxt_task_t *task, nxt_http_request_t *r, nxt_http_compress_conf_t *conf); |