comparison src/http/v2/ngx_http_v2.c @ 7295:89430899c72a

Added r->schema. For HTTP/1, it keeps scheme from the absolute form of URI. For HTTP/2, the :scheme request pseudo-header field value.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 07 Jun 2018 20:01:41 +0300
parents d588987701f4
children 8e6bb4e6045f
comparison
equal deleted inserted replaced
7294:21ad2af3262c 7295:89430899c72a
2614 ngx_http_v2_set_dependency(h2c, node, parent->node->id, 0); 2614 ngx_http_v2_set_dependency(h2c, node, parent->node->id, 0);
2615 2615
2616 r->method_name = ngx_http_core_get_method; 2616 r->method_name = ngx_http_core_get_method;
2617 r->method = NGX_HTTP_GET; 2617 r->method = NGX_HTTP_GET;
2618 2618
2619 r->schema_start = (u_char *) "https";
2620
2621 #if (NGX_HTTP_SSL) 2619 #if (NGX_HTTP_SSL)
2622 if (fc->ssl) { 2620 if (fc->ssl) {
2623 r->schema_end = r->schema_start + 5; 2621 ngx_str_set(&r->schema, "https");
2624 2622
2625 } else 2623 } else
2626 #endif 2624 #endif
2627 { 2625 {
2628 r->schema_end = r->schema_start + 4; 2626 ngx_str_set(&r->schema, "http");
2629 } 2627 }
2630 2628
2631 value.data = ngx_pstrdup(pool, path); 2629 value.data = ngx_pstrdup(pool, path);
2632 if (value.data == NULL) { 2630 if (value.data == NULL) {
2633 goto close; 2631 goto close;
3475 ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value) 3473 ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value)
3476 { 3474 {
3477 u_char c, ch; 3475 u_char c, ch;
3478 ngx_uint_t i; 3476 ngx_uint_t i;
3479 3477
3480 if (r->schema_start) { 3478 if (r->schema.len) {
3481 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3479 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3482 "client sent duplicate :scheme header"); 3480 "client sent duplicate :scheme header");
3483 3481
3484 return NGX_DECLINED; 3482 return NGX_DECLINED;
3485 } 3483 }
3509 "client sent invalid :scheme header: \"%V\"", value); 3507 "client sent invalid :scheme header: \"%V\"", value);
3510 3508
3511 return NGX_DECLINED; 3509 return NGX_DECLINED;
3512 } 3510 }
3513 3511
3514 r->schema_start = value->data; 3512 r->schema = *value;
3515 r->schema_end = value->data + value->len;
3516 3513
3517 return NGX_OK; 3514 return NGX_OK;
3518 } 3515 }
3519 3516
3520 3517
3573 u_char *p; 3570 u_char *p;
3574 3571
3575 static const u_char ending[] = " HTTP/2.0"; 3572 static const u_char ending[] = " HTTP/2.0";
3576 3573
3577 if (r->method_name.len == 0 3574 if (r->method_name.len == 0
3578 || r->schema_start == NULL 3575 || r->schema.len == 0
3579 || r->unparsed_uri.len == 0) 3576 || r->unparsed_uri.len == 0)
3580 { 3577 {
3581 if (r->method_name.len == 0) { 3578 if (r->method_name.len == 0) {
3582 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3579 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3583 "client sent no :method header"); 3580 "client sent no :method header");
3584 3581
3585 } else if (r->schema_start == NULL) { 3582 } else if (r->schema.len == 0) {
3586 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3583 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3587 "client sent no :scheme header"); 3584 "client sent no :scheme header");
3588 3585
3589 } else { 3586 } else {
3590 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3587 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,