Mercurial > hg > nginx
changeset 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 | 21ad2af3262c |
children | 8e6bb4e6045f |
files | src/http/ngx_http_core_module.c src/http/ngx_http_request.c src/http/ngx_http_request.h src/http/v2/ngx_http_v2.c |
diffstat | 4 files changed, 13 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/ngx_http_core_module.c Thu Jun 07 19:53:43 2018 +0300 +++ b/src/http/ngx_http_core_module.c Thu Jun 07 20:01:41 2018 +0300 @@ -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);
--- a/src/http/ngx_http_request.c Thu Jun 07 19:53:43 2018 +0300 +++ b/src/http/ngx_http_request.c Thu Jun 07 20:01:41 2018 +0300 @@ -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;
--- a/src/http/ngx_http_request.h Thu Jun 07 19:53:43 2018 +0300 +++ b/src/http/ngx_http_request.h Thu Jun 07 20:01:41 2018 +0300 @@ -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;
--- a/src/http/v2/ngx_http_v2.c Thu Jun 07 19:53:43 2018 +0300 +++ b/src/http/v2/ngx_http_v2.c Thu Jun 07 20:01:41 2018 +0300 @@ -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");