summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nxt_http_compress.c2
-rw-r--r--src/nxt_http_compress_gzip.c14
-rw-r--r--src/nxt_http_compress_gzip.h9
3 files changed, 22 insertions, 3 deletions
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);