diff options
| author | Andrew Clayton <a.clayton@nginx.com> | 2024-11-20 15:50:31 +0000 |
|---|---|---|
| committer | Andrew Clayton <a.clayton@nginx.com> | 2024-11-29 00:45:22 +0000 |
| commit | fd7d4c695777d3e34a4af9741600b591f8bbef79 (patch) | |
| tree | 4c3585d90e69fe14bdd9ad8c6e0e62f23d0dd562 /src/nxt_http_compression.h | |
| parent | dc638026cb460513a3339cb04b01ee40720f140c (diff) | |
| download | unit-fd7d4c695777d3e34a4af9741600b591f8bbef79.tar.gz unit-fd7d4c695777d3e34a4af9741600b591f8bbef79.tar.bz2 | |
http: Add core http compression code
This is the initial step to enabling HTTP compression on both static and
application responses.
This code itself doesn't do any actual compression, that will come in
subsequent commits. It just contains the core functions for initialising
structures that describe the available compressors and functions for
checking if compression should be done depending on various criteria.
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/nxt_http_compression.h')
| -rw-r--r-- | src/nxt_http_compression.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/nxt_http_compression.h b/src/nxt_http_compression.h new file mode 100644 index 00000000..3d84cb1d --- /dev/null +++ b/src/nxt_http_compression.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) Andrew Clayton + * Copyright (C) F5, Inc. + */ + +#ifndef _NXT_COMPRESSION_H_INCLUDED_ +#define _NXT_COMPRESSION_H_INCLUDED_ + +#include <nxt_auto_config.h> + +#include <stddef.h> +#include <stdint.h> +#include <stdbool.h> + +#include <nxt_main.h> +#include <nxt_router.h> +#include <nxt_string.h> +#include <nxt_conf.h> + + +typedef struct nxt_http_comp_compressor_ctx_s nxt_http_comp_compressor_ctx_t; +typedef struct nxt_http_comp_operations_s nxt_http_comp_operations_t; + +struct nxt_http_comp_compressor_ctx_s { + int8_t level; + + union { + }; +}; + +struct nxt_http_comp_operations_s { + void (*init)(nxt_http_comp_compressor_ctx_t *ctx); + size_t (*bound)(const nxt_http_comp_compressor_ctx_t *ctx, + size_t in_len); + ssize_t (*deflate)(nxt_http_comp_compressor_ctx_t *ctx, + const uint8_t *in_buf, size_t in_len, + uint8_t *out_buf, size_t out_len, bool last); + void (*free_ctx)(const nxt_http_comp_compressor_ctx_t *ctx); +}; + + +extern bool nxt_http_comp_wants_compression(void); +extern bool nxt_http_comp_compressor_is_valid(const nxt_str_t *token); +extern nxt_int_t nxt_http_comp_check_compression(nxt_task_t *task, + nxt_http_request_t *r); +extern nxt_int_t nxt_http_comp_compression_init(nxt_task_t *task, + nxt_router_conf_t *rtcf, const nxt_conf_value_t *comp_conf); + +#endif /* _NXT_COMPRESSION_H_INCLUDED_ */ |
