# HG changeset patch # User Roman Arutyunyan # Date 1620216563 -10800 # Node ID b43e50f47b2e50965c2bf08e05ed45ee2ce796f4 # Parent 345370fdd32df26973de918b27704bb6c6dec7e0 HTTP/3: separate header files for existing source files. diff --git a/auto/modules b/auto/modules --- a/auto/modules +++ b/auto/modules @@ -427,7 +427,10 @@ if [ $HTTP = YES ]; then ngx_module_name=ngx_http_v3_module ngx_module_incs=src/http/v3 ngx_module_deps="src/http/v3/ngx_http_v3.h \ - src/http/v3/ngx_http_v3_parse.h" + src/http/v3/ngx_http_v3_encode.h \ + src/http/v3/ngx_http_v3_parse.h \ + src/http/v3/ngx_http_v3_tables.h \ + src/http/v3/ngx_http_v3_streams.h" ngx_module_srcs="src/http/v3/ngx_http_v3_encode.c \ src/http/v3/ngx_http_v3_parse.c \ src/http/v3/ngx_http_v3_tables.c \ diff --git a/src/http/v3/ngx_http_v3.h b/src/http/v3/ngx_http_v3.h --- a/src/http/v3/ngx_http_v3.h +++ b/src/http/v3/ngx_http_v3.h @@ -12,7 +12,11 @@ #include #include #include + #include +#include +#include +#include #define NGX_HTTP_V3_ALPN_ADVERTISE "\x02h3" @@ -112,21 +116,6 @@ struct ngx_http_v3_parse_s { }; -typedef struct { - ngx_str_t name; - ngx_str_t value; -} ngx_http_v3_header_t; - - -typedef struct { - ngx_http_v3_header_t **elts; - ngx_uint_t nelts; - ngx_uint_t base; - size_t size; - size_t capacity; -} ngx_http_v3_dynamic_table_t; - - struct ngx_http_v3_session_s { ngx_http_v3_dynamic_table_t table; @@ -148,68 +137,11 @@ struct ngx_http_v3_session_s { void ngx_http_v3_init(ngx_connection_t *c); +ngx_int_t ngx_http_v3_init_session(ngx_connection_t *c); + ngx_int_t ngx_http_v3_read_request_body(ngx_http_request_t *r); ngx_int_t ngx_http_v3_read_unbuffered_request_body(ngx_http_request_t *r); -uintptr_t ngx_http_v3_encode_varlen_int(u_char *p, uint64_t value); -uintptr_t ngx_http_v3_encode_prefix_int(u_char *p, uint64_t value, - ngx_uint_t prefix); - -uintptr_t ngx_http_v3_encode_header_block_prefix(u_char *p, - ngx_uint_t insert_count, ngx_uint_t sign, ngx_uint_t delta_base); -uintptr_t ngx_http_v3_encode_header_ri(u_char *p, ngx_uint_t dynamic, - ngx_uint_t index); -uintptr_t ngx_http_v3_encode_header_lri(u_char *p, ngx_uint_t dynamic, - ngx_uint_t index, u_char *data, size_t len); -uintptr_t ngx_http_v3_encode_header_l(u_char *p, ngx_str_t *name, - ngx_str_t *value); -uintptr_t ngx_http_v3_encode_header_pbi(u_char *p, ngx_uint_t index); -uintptr_t ngx_http_v3_encode_header_lpbi(u_char *p, ngx_uint_t index, - u_char *data, size_t len); - -ngx_int_t ngx_http_v3_init_session(ngx_connection_t *c); -void ngx_http_v3_init_uni_stream(ngx_connection_t *c); -ngx_int_t ngx_http_v3_register_uni_stream(ngx_connection_t *c, uint64_t type); -ngx_connection_t *ngx_http_v3_create_push_stream(ngx_connection_t *c, - uint64_t push_id); -ngx_int_t ngx_http_v3_send_goaway(ngx_connection_t *c, uint64_t id); -ngx_int_t ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, - ngx_uint_t index, ngx_str_t *value); -ngx_int_t ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name, - ngx_str_t *value); -ngx_int_t ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity); -ngx_int_t ngx_http_v3_duplicate(ngx_connection_t *c, ngx_uint_t index); -ngx_int_t ngx_http_v3_ack_header(ngx_connection_t *c, ngx_uint_t stream_id); -ngx_int_t ngx_http_v3_cancel_stream(ngx_connection_t *c, ngx_uint_t stream_id); -ngx_int_t ngx_http_v3_inc_insert_count(ngx_connection_t *c, ngx_uint_t inc); -ngx_int_t ngx_http_v3_lookup_static(ngx_connection_t *c, ngx_uint_t index, - ngx_str_t *name, ngx_str_t *value); -ngx_int_t ngx_http_v3_lookup(ngx_connection_t *c, ngx_uint_t index, - ngx_str_t *name, ngx_str_t *value); -ngx_int_t ngx_http_v3_decode_insert_count(ngx_connection_t *c, - ngx_uint_t *insert_count); -ngx_int_t ngx_http_v3_check_insert_count(ngx_connection_t *c, - ngx_uint_t insert_count); -ngx_int_t ngx_http_v3_set_param(ngx_connection_t *c, uint64_t id, - uint64_t value); -ngx_int_t ngx_http_v3_set_max_push_id(ngx_connection_t *c, - uint64_t max_push_id); -ngx_int_t ngx_http_v3_cancel_push(ngx_connection_t *c, uint64_t push_id); - -ngx_int_t ngx_http_v3_send_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, - ngx_uint_t index, ngx_str_t *value); -ngx_int_t ngx_http_v3_send_insert(ngx_connection_t *c, ngx_str_t *name, - ngx_str_t *value); -ngx_int_t ngx_http_v3_send_set_capacity(ngx_connection_t *c, - ngx_uint_t capacity); -ngx_int_t ngx_http_v3_send_duplicate(ngx_connection_t *c, ngx_uint_t index); -ngx_int_t ngx_http_v3_send_ack_header(ngx_connection_t *c, - ngx_uint_t stream_id); -ngx_int_t ngx_http_v3_send_cancel_stream(ngx_connection_t *c, - ngx_uint_t stream_id); -ngx_int_t ngx_http_v3_send_inc_insert_count(ngx_connection_t *c, - ngx_uint_t inc); - extern ngx_module_t ngx_http_v3_module; diff --git a/src/http/v3/ngx_http_v3_encode.h b/src/http/v3/ngx_http_v3_encode.h new file mode 100644 --- /dev/null +++ b/src/http/v3/ngx_http_v3_encode.h @@ -0,0 +1,34 @@ + +/* + * Copyright (C) Roman Arutyunyan + * Copyright (C) Nginx, Inc. + */ + + +#ifndef _NGX_HTTP_V3_ENCODE_H_INCLUDED_ +#define _NGX_HTTP_V3_ENCODE_H_INCLUDED_ + + +#include +#include +#include + + +uintptr_t ngx_http_v3_encode_varlen_int(u_char *p, uint64_t value); +uintptr_t ngx_http_v3_encode_prefix_int(u_char *p, uint64_t value, + ngx_uint_t prefix); + +uintptr_t ngx_http_v3_encode_header_block_prefix(u_char *p, + ngx_uint_t insert_count, ngx_uint_t sign, ngx_uint_t delta_base); +uintptr_t ngx_http_v3_encode_header_ri(u_char *p, ngx_uint_t dynamic, + ngx_uint_t index); +uintptr_t ngx_http_v3_encode_header_lri(u_char *p, ngx_uint_t dynamic, + ngx_uint_t index, u_char *data, size_t len); +uintptr_t ngx_http_v3_encode_header_l(u_char *p, ngx_str_t *name, + ngx_str_t *value); +uintptr_t ngx_http_v3_encode_header_pbi(u_char *p, ngx_uint_t index); +uintptr_t ngx_http_v3_encode_header_lpbi(u_char *p, ngx_uint_t index, + u_char *data, size_t len); + + +#endif /* _NGX_HTTP_V3_ENCODE_H_INCLUDED_ */ diff --git a/src/http/v3/ngx_http_v3_streams.h b/src/http/v3/ngx_http_v3_streams.h new file mode 100644 --- /dev/null +++ b/src/http/v3/ngx_http_v3_streams.h @@ -0,0 +1,43 @@ + +/* + * Copyright (C) Roman Arutyunyan + * Copyright (C) Nginx, Inc. + */ + + +#ifndef _NGX_HTTP_V3_STREAMS_H_INCLUDED_ +#define _NGX_HTTP_V3_STREAMS_H_INCLUDED_ + + +#include +#include +#include + + +void ngx_http_v3_init_uni_stream(ngx_connection_t *c); +ngx_int_t ngx_http_v3_register_uni_stream(ngx_connection_t *c, uint64_t type); + +ngx_connection_t *ngx_http_v3_create_push_stream(ngx_connection_t *c, + uint64_t push_id); +ngx_int_t ngx_http_v3_set_max_push_id(ngx_connection_t *c, + uint64_t max_push_id); +ngx_int_t ngx_http_v3_cancel_push(ngx_connection_t *c, uint64_t push_id); +ngx_int_t ngx_http_v3_cancel_stream(ngx_connection_t *c, ngx_uint_t stream_id); + +ngx_int_t ngx_http_v3_send_goaway(ngx_connection_t *c, uint64_t id); +ngx_int_t ngx_http_v3_send_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, + ngx_uint_t index, ngx_str_t *value); +ngx_int_t ngx_http_v3_send_insert(ngx_connection_t *c, ngx_str_t *name, + ngx_str_t *value); +ngx_int_t ngx_http_v3_send_set_capacity(ngx_connection_t *c, + ngx_uint_t capacity); +ngx_int_t ngx_http_v3_send_duplicate(ngx_connection_t *c, ngx_uint_t index); +ngx_int_t ngx_http_v3_send_ack_header(ngx_connection_t *c, + ngx_uint_t stream_id); +ngx_int_t ngx_http_v3_send_cancel_stream(ngx_connection_t *c, + ngx_uint_t stream_id); +ngx_int_t ngx_http_v3_send_inc_insert_count(ngx_connection_t *c, + ngx_uint_t inc); + + +#endif /* _NGX_HTTP_V3_STREAMS_H_INCLUDED_ */ diff --git a/src/http/v3/ngx_http_v3_tables.h b/src/http/v3/ngx_http_v3_tables.h new file mode 100644 --- /dev/null +++ b/src/http/v3/ngx_http_v3_tables.h @@ -0,0 +1,52 @@ + +/* + * Copyright (C) Roman Arutyunyan + * Copyright (C) Nginx, Inc. + */ + + +#ifndef _NGX_HTTP_V3_TABLES_H_INCLUDED_ +#define _NGX_HTTP_V3_TABLES_H_INCLUDED_ + + +#include +#include +#include + + +typedef struct { + ngx_str_t name; + ngx_str_t value; +} ngx_http_v3_header_t; + + +typedef struct { + ngx_http_v3_header_t **elts; + ngx_uint_t nelts; + ngx_uint_t base; + size_t size; + size_t capacity; +} ngx_http_v3_dynamic_table_t; + + +ngx_int_t ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, + ngx_uint_t index, ngx_str_t *value); +ngx_int_t ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name, + ngx_str_t *value); +ngx_int_t ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity); +ngx_int_t ngx_http_v3_duplicate(ngx_connection_t *c, ngx_uint_t index); +ngx_int_t ngx_http_v3_ack_header(ngx_connection_t *c, ngx_uint_t stream_id); +ngx_int_t ngx_http_v3_inc_insert_count(ngx_connection_t *c, ngx_uint_t inc); +ngx_int_t ngx_http_v3_lookup_static(ngx_connection_t *c, ngx_uint_t index, + ngx_str_t *name, ngx_str_t *value); +ngx_int_t ngx_http_v3_lookup(ngx_connection_t *c, ngx_uint_t index, + ngx_str_t *name, ngx_str_t *value); +ngx_int_t ngx_http_v3_decode_insert_count(ngx_connection_t *c, + ngx_uint_t *insert_count); +ngx_int_t ngx_http_v3_check_insert_count(ngx_connection_t *c, + ngx_uint_t insert_count); +ngx_int_t ngx_http_v3_set_param(ngx_connection_t *c, uint64_t id, + uint64_t value); + + +#endif /* _NGX_HTTP_V3_TABLES_H_INCLUDED_ */