comparison src/http/v3/ngx_http_v3_request.c @ 8234:9dce2978e4fd quic

HTTP/3: eliminated r->method_start. The field was introduced to ease parsing HTTP/3 requests. The change reduces diff to the default branch.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 25 Nov 2020 17:57:43 +0000
parents 279ad36f2f4b
children 1efee5e4194c
comparison
equal deleted inserted replaced
8233:5a92523e50d3 8234:9dce2978e4fd
127 127
128 if (n == NGX_OK && rc == NGX_OK) { 128 if (n == NGX_OK && rc == NGX_OK) {
129 continue; 129 continue;
130 } 130 }
131 131
132 ngx_str_set(&r->http_protocol, "HTTP/3.0"); 132 len = r->method_name.len + 1
133
134 len = (r->method_end - r->method_start) + 1
135 + (r->uri_end - r->uri_start) + 1 133 + (r->uri_end - r->uri_start) + 1
136 + sizeof("HTTP/3") - 1; 134 + sizeof("HTTP/3.0") - 1;
137 135
138 p = ngx_pnalloc(c->pool, len); 136 p = ngx_pnalloc(c->pool, len);
139 if (p == NULL) { 137 if (p == NULL) {
140 goto failed; 138 goto failed;
141 } 139 }
142 140
143 r->request_start = p; 141 r->request_start = p;
144 142
145 p = ngx_cpymem(p, r->method_start, r->method_end - r->method_start); 143 p = ngx_cpymem(p, r->method_name.data, r->method_name.len);
144 r->method_end = p - 1;
146 *p++ = ' '; 145 *p++ = ' ';
147 p = ngx_cpymem(p, r->uri_start, r->uri_end - r->uri_start); 146 p = ngx_cpymem(p, r->uri_start, r->uri_end - r->uri_start);
148 *p++ = ' '; 147 *p++ = ' ';
149 p = ngx_cpymem(p, "HTTP/3", sizeof("HTTP/3") - 1); 148 r->http_protocol.data = p;
149 p = ngx_cpymem(p, "HTTP/3.0", sizeof("HTTP/3.0") - 1);
150 150
151 r->request_end = p; 151 r->request_end = p;
152 r->state = 0; 152 r->state = 0;
153 153
154 return NGX_OK; 154 return NGX_OK;
307 } 307 }
308 308
309 c = r->connection; 309 c = r->connection;
310 310
311 if (name->len == 7 && ngx_strncmp(name->data, ":method", 7) == 0) { 311 if (name->len == 7 && ngx_strncmp(name->data, ":method", 7) == 0) {
312 r->method_start = value->data; 312 r->method_name = *value;
313 r->method_end = value->data + value->len;
314 313
315 for (i = 0; i < sizeof(ngx_http_v3_methods) 314 for (i = 0; i < sizeof(ngx_http_v3_methods)
316 / sizeof(ngx_http_v3_methods[0]); i++) 315 / sizeof(ngx_http_v3_methods[0]); i++)
317 { 316 {
318 if (value->len == ngx_http_v3_methods[i].name.len 317 if (value->len == ngx_http_v3_methods[i].name.len