mirror of
https://github.com/nginx/nginx.git
synced 2024-12-05 06:19:01 +08:00
HTTP/3: eliminated r->method_start.
The field was introduced to ease parsing HTTP/3 requests. The change reduces diff to the default branch.
This commit is contained in:
parent
9129fb3db9
commit
7cfc5eb11f
@ -145,7 +145,6 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|||||||
case sw_start:
|
case sw_start:
|
||||||
r->parse_start = p;
|
r->parse_start = p;
|
||||||
r->request_start = p;
|
r->request_start = p;
|
||||||
r->method_start = p;
|
|
||||||
|
|
||||||
if (ch == CR || ch == LF) {
|
if (ch == CR || ch == LF) {
|
||||||
break;
|
break;
|
||||||
@ -160,7 +159,7 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
|
|||||||
|
|
||||||
case sw_method:
|
case sw_method:
|
||||||
if (ch == ' ') {
|
if (ch == ' ') {
|
||||||
r->method_end = p;
|
r->method_end = p - 1;
|
||||||
m = r->request_start;
|
m = r->request_start;
|
||||||
|
|
||||||
switch (p - m) {
|
switch (p - m) {
|
||||||
@ -833,10 +832,6 @@ done:
|
|||||||
r->request_end = p;
|
r->request_end = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r->http_protocol.data) {
|
|
||||||
r->http_protocol.len = r->request_end - r->http_protocol.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
r->http_version = r->http_major * 1000 + r->http_minor;
|
r->http_version = r->http_major * 1000 + r->http_minor;
|
||||||
r->state = sw_start;
|
r->state = sw_start;
|
||||||
|
|
||||||
|
@ -1162,8 +1162,12 @@ ngx_http_process_request_line(ngx_event_t *rev)
|
|||||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||||
"http request line: \"%V\"", &r->request_line);
|
"http request line: \"%V\"", &r->request_line);
|
||||||
|
|
||||||
r->method_name.len = r->method_end - r->method_start;
|
r->method_name.len = r->method_end - r->request_start + 1;
|
||||||
r->method_name.data = r->method_start;
|
r->method_name.data = r->request_line.data;
|
||||||
|
|
||||||
|
if (r->http_protocol.data) {
|
||||||
|
r->http_protocol.len = r->request_end - r->http_protocol.data;
|
||||||
|
}
|
||||||
|
|
||||||
if (ngx_http_process_request_uri(r) != NGX_OK) {
|
if (ngx_http_process_request_uri(r) != NGX_OK) {
|
||||||
break;
|
break;
|
||||||
|
@ -585,7 +585,6 @@ struct ngx_http_request_s {
|
|||||||
u_char *args_start;
|
u_char *args_start;
|
||||||
u_char *request_start;
|
u_char *request_start;
|
||||||
u_char *request_end;
|
u_char *request_end;
|
||||||
u_char *method_start;
|
|
||||||
u_char *method_end;
|
u_char *method_end;
|
||||||
u_char *schema_start;
|
u_char *schema_start;
|
||||||
u_char *schema_end;
|
u_char *schema_end;
|
||||||
|
@ -129,11 +129,9 @@ ngx_http_v3_parse_request(ngx_http_request_t *r, ngx_buf_t *b)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_str_set(&r->http_protocol, "HTTP/3.0");
|
len = r->method_name.len + 1
|
||||||
|
|
||||||
len = (r->method_end - r->method_start) + 1
|
|
||||||
+ (r->uri_end - r->uri_start) + 1
|
+ (r->uri_end - r->uri_start) + 1
|
||||||
+ sizeof("HTTP/3") - 1;
|
+ sizeof("HTTP/3.0") - 1;
|
||||||
|
|
||||||
p = ngx_pnalloc(c->pool, len);
|
p = ngx_pnalloc(c->pool, len);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
@ -142,11 +140,13 @@ ngx_http_v3_parse_request(ngx_http_request_t *r, ngx_buf_t *b)
|
|||||||
|
|
||||||
r->request_start = p;
|
r->request_start = p;
|
||||||
|
|
||||||
p = ngx_cpymem(p, r->method_start, r->method_end - r->method_start);
|
p = ngx_cpymem(p, r->method_name.data, r->method_name.len);
|
||||||
|
r->method_end = p - 1;
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
p = ngx_cpymem(p, r->uri_start, r->uri_end - r->uri_start);
|
p = ngx_cpymem(p, r->uri_start, r->uri_end - r->uri_start);
|
||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
p = ngx_cpymem(p, "HTTP/3", sizeof("HTTP/3") - 1);
|
r->http_protocol.data = p;
|
||||||
|
p = ngx_cpymem(p, "HTTP/3.0", sizeof("HTTP/3.0") - 1);
|
||||||
|
|
||||||
r->request_end = p;
|
r->request_end = p;
|
||||||
r->state = 0;
|
r->state = 0;
|
||||||
@ -309,8 +309,7 @@ ngx_http_v3_process_pseudo_header(ngx_http_request_t *r, ngx_str_t *name,
|
|||||||
c = r->connection;
|
c = r->connection;
|
||||||
|
|
||||||
if (name->len == 7 && ngx_strncmp(name->data, ":method", 7) == 0) {
|
if (name->len == 7 && ngx_strncmp(name->data, ":method", 7) == 0) {
|
||||||
r->method_start = value->data;
|
r->method_name = *value;
|
||||||
r->method_end = value->data + value->len;
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(ngx_http_v3_methods)
|
for (i = 0; i < sizeof(ngx_http_v3_methods)
|
||||||
/ sizeof(ngx_http_v3_methods[0]); i++)
|
/ sizeof(ngx_http_v3_methods[0]); i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user