summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_compress.c
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@nginx.com>2023-07-19 14:22:21 +0200
committerAlejandro Colomar <alx@kernel.org>2023-10-25 13:37:58 +0200
commitfd4f4e4c5943c3bcd09e3bdcbeefc263aa2f1937 (patch)
tree5c91e83b03f5dd9b975fadfa2cb2cf6e03b653a2 /src/nxt_http_compress.c
parentddb7d61f6173c2f191f4eddc15f1f912e940e42c (diff)
downloadunit-fd4f4e4c5943c3bcd09e3bdcbeefc263aa2f1937.tar.gz
unit-fd4f4e4c5943c3bcd09e3bdcbeefc263aa2f1937.tar.bz2
HTTP: compress: added "compress" action.
There are still no supported encodings. This is just infrastructure for the next commits, which will add gzip compression. Signed-off-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'src/nxt_http_compress.c')
-rw-r--r--src/nxt_http_compress.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/nxt_http_compress.c b/src/nxt_http_compress.c
new file mode 100644
index 00000000..0f3d8a89
--- /dev/null
+++ b/src/nxt_http_compress.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) Alejandro Colomar
+ * Copyright (C) NGINX, Inc.
+ */
+
+
+#include "nxt_http_compress.h"
+
+#include <stddef.h>
+
+#include <nxt_unit_cdefs.h>
+
+#include "nxt_clang.h"
+#include "nxt_conf.h"
+#include "nxt_errno.h"
+#include "nxt_http.h"
+#include "nxt_list.h"
+#include "nxt_main.h"
+#include "nxt_mp.h"
+#include "nxt_router.h"
+#include "nxt_string.h"
+#include "nxt_types.h"
+
+
+static nxt_conf_map_t nxt_http_compress_conf[] = {
+ {
+ nxt_string("encoding"),
+ NXT_CONF_MAP_STR,
+ offsetof(nxt_http_compress_conf_t, encoding),
+ },
+};
+
+
+nxt_int_t
+nxt_http_compress_init(nxt_router_conf_t *rtcf, nxt_http_action_t *action,
+ nxt_http_action_conf_t *acf)
+{
+ nxt_mp_t *mp;
+ nxt_int_t ret;
+ nxt_http_compress_conf_t *conf;
+
+ mp = rtcf->mem_pool;
+
+ conf = nxt_mp_zget(mp, sizeof(nxt_http_compress_conf_t));
+ if (nxt_slow_path(conf == NULL)) {
+ return NXT_ERROR;
+ }
+
+ 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)) {
+ return NXT_ERROR;
+ }
+
+ if (0) {
+
+ } else {
+ return NXT_ERROR;
+ }
+
+ action->compress = conf;
+
+ return NXT_OK;
+}
+
+
+nxt_int_t
+nxt_http_compress_append_field(nxt_task_t *task, nxt_http_request_t *r,
+ nxt_str_t *field, nxt_str_t *value)
+{
+ nxt_http_field_t *f;
+
+ f = nxt_list_add(r->resp.fields);
+ if (nxt_slow_path(f == NULL)) {
+ return NXT_ERROR;
+ }
+
+ f->hash = 0;
+ f->skip = 0;
+ f->hopbyhop = 0;
+
+ f->name_length = field->length;
+ f->value_length = value->length;
+ f->name = field->start;
+ f->value = value->start;
+
+ return NXT_OK;
+}