97 lines
2.6 KiB
C
97 lines
2.6 KiB
C
/*************************************************************************
|
|
> File Name: http2_common.h
|
|
> Author:
|
|
> Mail:
|
|
> Created Time: 2018年09月21日 星期五 13时59分12秒
|
|
************************************************************************/
|
|
|
|
#ifndef _HTTP2_STRING_H
|
|
#define _HTTP2_STRING_H
|
|
|
|
#include <zlib.h>
|
|
#include <sys/queue.h>
|
|
#include <brotli/encode.h>
|
|
#include <brotli/decode.h>
|
|
#include <http2_stream.h>
|
|
#include <zstd.h>
|
|
#include <zdict.h>
|
|
|
|
typedef struct RTLogInit2Data_
|
|
{
|
|
void *handle;
|
|
} RTLogInit2Data;
|
|
|
|
typedef struct Http2Plugin_
|
|
{
|
|
struct event * event[TFE_THREAD_MAX];
|
|
struct tfe_h2_stream h2_stream[TFE_THREAD_MAX];
|
|
} Http2Plugin;
|
|
|
|
enum http_request_method
|
|
{
|
|
HTTP_REQUEST_METHOD_DELETE = 0,
|
|
HTTP_REQUEST_METHOD_GET = 1,
|
|
HTTP_REQUEST_METHOD_HEAD = 2,
|
|
HTTP_REQUEST_METHOD_POST = 3,
|
|
HTTP_REQUEST_METHOD_PUT = 4,
|
|
HTTP_REQUEST_METHOD_CONNECT = 5,
|
|
HTTP_REQUEST_METHOD_OPTIONS = 6,
|
|
HTTP_REQUEST_METHOD_UNKNOWN,
|
|
};
|
|
|
|
enum http_resp_code
|
|
{
|
|
HTTP_RESP_CODE_100 = 100,
|
|
HTTP_RESP_CODE_101 = 101,
|
|
HTTP_RESP_CODE_102 = 102,
|
|
HTTP_RESP_CODE_103 = 103,
|
|
HTTP_RESP_CODE_200 = 200,
|
|
};
|
|
|
|
struct value_string
|
|
{
|
|
unsigned int value;
|
|
const char *strptr;
|
|
};
|
|
|
|
const char*
|
|
val_to_str(unsigned int val, const struct value_string *vs);
|
|
|
|
int
|
|
str_to_val(const char *val, const struct value_string *vs);
|
|
|
|
const char*
|
|
http2_header_val_to_str(unsigned int val, const char * map[], unsigned int map_size);
|
|
int
|
|
http2_header_str_to_val(const char *str, size_t slen, const char * map[], unsigned int map_size);
|
|
|
|
#define BV(x) (1 << x)
|
|
#define HTTP2_CONTENT_ENCODING_NONE 0
|
|
#define HTTP2_CONTENT_ENCODING_GZIP BV(1)
|
|
#define HTTP2_CONTENT_ENCODING_DEFLATE BV(2)
|
|
#define HTTP2_CONTENT_ENCODING_COMPRESS BV(3)
|
|
#define HTTP2_CONTENT_ENCODING_BZIP2 BV(4)
|
|
#define HTTP2_CONTENT_ENCODING_X_GZIP BV(5)
|
|
#define HTTP2_CONTENT_ENCODING_X_BZIP2 BV(6)
|
|
#define HTTP2_CONTENT_ENCODING_BR BV(7)
|
|
#define HTTP2_CONTENT_ENCODING_ZSTD BV(8)
|
|
|
|
struct http2_codec_ctx
|
|
{
|
|
z_stream zst;
|
|
BrotliDecoderState *brdec_state;
|
|
BrotliEncoderState *brenc_state;
|
|
ZSTD_DCtx* dctx;
|
|
ZSTD_CCtx* cctx;
|
|
};
|
|
|
|
RTLogInit2Data *logger();
|
|
|
|
Http2Plugin *http2_plugin();
|
|
|
|
int http2_decompress_stream(const uint8_t *source, int len, char **dest, int *outlen, struct http2_codec_ctx **codec_ctx, int encode);
|
|
int http2_compress_stream(struct http2_codec_ctx **codec_ctx, const uint8_t *source, int slen, struct evbuffer * evbuf, int encode, int mode);
|
|
void http2_compress_finished(struct http2_codec_ctx **codec_ctx);
|
|
void http2_decompress_finished(struct http2_codec_ctx **codec_ctx);
|
|
#endif
|