comparison src/http/v3/ngx_http_v3_request.c @ 8706:3057bae4dba7 quic

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.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 17 Feb 2021 15:56:34 +0300
parents a9034b10dacc
children ffcaf0aad9f2
comparison
equal deleted inserted replaced
8705:ae2e68f206f9 8706:3057bae4dba7
110 return; 110 return;
111 } 111 }
112 112
113 r->http_version = NGX_HTTP_VERSION_30; 113 r->http_version = NGX_HTTP_VERSION_30;
114 114
115 r->v3_parse = ngx_pcalloc(r->pool, sizeof(ngx_http_v3_parse_t));
116 if (r->v3_parse == NULL) {
117 ngx_http_close_connection(c);
118 return;
119 }
120
115 c->data = r; 121 c->data = r;
116 122
117 rev = c->read; 123 rev = c->read;
118 rev->handler = ngx_http_v3_process_request; 124 rev->handler = ngx_http_v3_process_request;
119 125
142 c->timedout = 1; 148 c->timedout = 1;
143 ngx_http_close_request(r, NGX_HTTP_REQUEST_TIME_OUT); 149 ngx_http_close_request(r, NGX_HTTP_REQUEST_TIME_OUT);
144 return; 150 return;
145 } 151 }
146 152
147 st = r->h3_parse; 153 st = &r->v3_parse->headers;
148
149 if (st == NULL) {
150 st = ngx_pcalloc(c->pool, sizeof(ngx_http_v3_parse_headers_t));
151 if (st == NULL) {
152 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
153 return;
154 }
155
156 r->h3_parse = st;
157 }
158 154
159 b = r->header_in; 155 b = r->header_in;
160 156
161 for ( ;; ) { 157 for ( ;; ) {
162 158
947 ngx_http_core_loc_conf_t *clcf; 943 ngx_http_core_loc_conf_t *clcf;
948 ngx_http_core_srv_conf_t *cscf; 944 ngx_http_core_srv_conf_t *cscf;
949 ngx_http_v3_parse_data_t *st; 945 ngx_http_v3_parse_data_t *st;
950 946
951 rb = r->request_body; 947 rb = r->request_body;
952 st = r->h3_parse; 948 st = &r->v3_parse->body;
953 949
954 if (rb->rest == -1) { 950 if (rb->rest == -1) {
955 951
956 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 952 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
957 "http3 request body filter"); 953 "http3 request body filter");
958
959 st = ngx_pcalloc(r->pool, sizeof(ngx_http_v3_parse_data_t));
960 if (st == NULL) {
961 return NGX_HTTP_INTERNAL_SERVER_ERROR;
962 }
963
964 r->h3_parse = st;
965 954
966 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); 955 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
967 956
968 rb->rest = cscf->large_client_header_buffers.size; 957 rb->rest = cscf->large_client_header_buffers.size;
969 } 958 }