mirror of
https://github.com/nginx/nginx.git
synced 2024-12-12 02:09:04 +08:00
HTTP/3: introduced ngx_http_v3_parse_t structure.
The structure is used to parse an HTTP/3 request. An object of this type is added to ngx_http_request_t instead of h3_parse generic pointer. Also, the new field is located outside of the request ephemeral zone to keep it safe after request headers are parsed.
This commit is contained in:
parent
c83be09720
commit
ffb099bf52
@ -20,6 +20,7 @@ typedef struct ngx_http_file_cache_s ngx_http_file_cache_t;
|
||||
typedef struct ngx_http_log_ctx_s ngx_http_log_ctx_t;
|
||||
typedef struct ngx_http_chunked_s ngx_http_chunked_t;
|
||||
typedef struct ngx_http_v2_stream_s ngx_http_v2_stream_t;
|
||||
typedef struct ngx_http_v3_parse_s ngx_http_v3_parse_t;
|
||||
|
||||
typedef ngx_int_t (*ngx_http_header_handler_pt)(ngx_http_request_t *r,
|
||||
ngx_table_elt_t *h, ngx_uint_t offset);
|
||||
|
@ -447,6 +447,7 @@ struct ngx_http_request_s {
|
||||
|
||||
ngx_http_connection_t *http_connection;
|
||||
ngx_http_v2_stream_t *stream;
|
||||
ngx_http_v3_parse_t *v3_parse;
|
||||
|
||||
ngx_http_log_handler_pt log_handler;
|
||||
|
||||
@ -596,10 +597,6 @@ struct ngx_http_request_s {
|
||||
u_char *port_start;
|
||||
u_char *port_end;
|
||||
|
||||
#if (NGX_HTTP_V3)
|
||||
void *h3_parse;
|
||||
#endif
|
||||
|
||||
unsigned http_minor:16;
|
||||
unsigned http_major:16;
|
||||
};
|
||||
|
@ -98,6 +98,12 @@ typedef struct {
|
||||
} ngx_http_v3_loc_conf_t;
|
||||
|
||||
|
||||
struct ngx_http_v3_parse_s {
|
||||
ngx_http_v3_parse_headers_t headers;
|
||||
ngx_http_v3_parse_data_t body;
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_str_t name;
|
||||
ngx_str_t value;
|
||||
|
@ -112,6 +112,12 @@ ngx_http_v3_init(ngx_connection_t *c)
|
||||
|
||||
r->http_version = NGX_HTTP_VERSION_30;
|
||||
|
||||
r->v3_parse = ngx_pcalloc(r->pool, sizeof(ngx_http_v3_parse_t));
|
||||
if (r->v3_parse == NULL) {
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
}
|
||||
|
||||
c->data = r;
|
||||
|
||||
rev = c->read;
|
||||
@ -144,17 +150,7 @@ ngx_http_v3_process_request(ngx_event_t *rev)
|
||||
return;
|
||||
}
|
||||
|
||||
st = r->h3_parse;
|
||||
|
||||
if (st == NULL) {
|
||||
st = ngx_pcalloc(c->pool, sizeof(ngx_http_v3_parse_headers_t));
|
||||
if (st == NULL) {
|
||||
ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
|
||||
return;
|
||||
}
|
||||
|
||||
r->h3_parse = st;
|
||||
}
|
||||
st = &r->v3_parse->headers;
|
||||
|
||||
b = r->header_in;
|
||||
|
||||
@ -949,20 +945,13 @@ ngx_http_v3_request_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
||||
ngx_http_v3_parse_data_t *st;
|
||||
|
||||
rb = r->request_body;
|
||||
st = r->h3_parse;
|
||||
st = &r->v3_parse->body;
|
||||
|
||||
if (rb->rest == -1) {
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http3 request body filter");
|
||||
|
||||
st = ngx_pcalloc(r->pool, sizeof(ngx_http_v3_parse_data_t));
|
||||
if (st == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
r->h3_parse = st;
|
||||
|
||||
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
||||
|
||||
rb->rest = cscf->large_client_header_buffers.size;
|
||||
|
Loading…
Reference in New Issue
Block a user