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.
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 2d8fdb8..c57ec00 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c
@@ -2318,6 +2318,7 @@ sr->unparsed_uri = r->unparsed_uri; sr->method_name = ngx_http_core_get_method; sr->http_protocol = r->http_protocol; + sr->schema = r->schema; ngx_http_set_exten(sr);
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 210994b..0432c91 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c
@@ -987,6 +987,11 @@ return; } + if (r->schema_end) { + r->schema.len = r->schema_end - r->schema_start; + r->schema.data = r->schema_start; + } + if (r->host_end) { host.len = r->host_end - r->host_start;
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index 39baa0f..6bfff96 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h
@@ -412,6 +412,7 @@ ngx_str_t method_name; ngx_str_t http_protocol; + ngx_str_t schema; ngx_chain_t *out; ngx_http_request_t *main;
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c index a35140c..d3fdf05 100644 --- a/src/http/v2/ngx_http_v2.c +++ b/src/http/v2/ngx_http_v2.c
@@ -2616,16 +2616,14 @@ r->method_name = ngx_http_core_get_method; r->method = NGX_HTTP_GET; - r->schema_start = (u_char *) "https"; - #if (NGX_HTTP_SSL) if (fc->ssl) { - r->schema_end = r->schema_start + 5; + ngx_str_set(&r->schema, "https"); } else #endif { - r->schema_end = r->schema_start + 4; + ngx_str_set(&r->schema, "http"); } value.data = ngx_pstrdup(pool, path); @@ -3477,7 +3475,7 @@ u_char c, ch; ngx_uint_t i; - if (r->schema_start) { + if (r->schema.len) { ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, "client sent duplicate :scheme header"); @@ -3511,8 +3509,7 @@ return NGX_DECLINED; } - r->schema_start = value->data; - r->schema_end = value->data + value->len; + r->schema = *value; return NGX_OK; } @@ -3575,14 +3572,14 @@ static const u_char ending[] = " HTTP/2.0"; if (r->method_name.len == 0 - || r->schema_start == NULL + || r->schema.len == 0 || r->unparsed_uri.len == 0) { if (r->method_name.len == 0) { ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, "client sent no :method header"); - } else if (r->schema_start == NULL) { + } else if (r->schema.len == 0) { ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, "client sent no :scheme header");