mirror of
https://github.com/nginx/nginx.git
synced 2025-06-08 02:02:38 +08:00
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.
This commit is contained in:
parent
70b6e7a299
commit
f11a9cbdd0
@ -2318,6 +2318,7 @@ ngx_http_subrequest(ngx_http_request_t *r,
|
|||||||
sr->unparsed_uri = r->unparsed_uri;
|
sr->unparsed_uri = r->unparsed_uri;
|
||||||
sr->method_name = ngx_http_core_get_method;
|
sr->method_name = ngx_http_core_get_method;
|
||||||
sr->http_protocol = r->http_protocol;
|
sr->http_protocol = r->http_protocol;
|
||||||
|
sr->schema = r->schema;
|
||||||
|
|
||||||
ngx_http_set_exten(sr);
|
ngx_http_set_exten(sr);
|
||||||
|
|
||||||
|
@ -987,6 +987,11 @@ ngx_http_process_request_line(ngx_event_t *rev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r->schema_end) {
|
||||||
|
r->schema.len = r->schema_end - r->schema_start;
|
||||||
|
r->schema.data = r->schema_start;
|
||||||
|
}
|
||||||
|
|
||||||
if (r->host_end) {
|
if (r->host_end) {
|
||||||
|
|
||||||
host.len = r->host_end - r->host_start;
|
host.len = r->host_end - r->host_start;
|
||||||
|
@ -412,6 +412,7 @@ struct ngx_http_request_s {
|
|||||||
|
|
||||||
ngx_str_t method_name;
|
ngx_str_t method_name;
|
||||||
ngx_str_t http_protocol;
|
ngx_str_t http_protocol;
|
||||||
|
ngx_str_t schema;
|
||||||
|
|
||||||
ngx_chain_t *out;
|
ngx_chain_t *out;
|
||||||
ngx_http_request_t *main;
|
ngx_http_request_t *main;
|
||||||
|
@ -2616,16 +2616,14 @@ ngx_http_v2_push_stream(ngx_http_v2_stream_t *parent, ngx_str_t *path)
|
|||||||
r->method_name = ngx_http_core_get_method;
|
r->method_name = ngx_http_core_get_method;
|
||||||
r->method = NGX_HTTP_GET;
|
r->method = NGX_HTTP_GET;
|
||||||
|
|
||||||
r->schema_start = (u_char *) "https";
|
|
||||||
|
|
||||||
#if (NGX_HTTP_SSL)
|
#if (NGX_HTTP_SSL)
|
||||||
if (fc->ssl) {
|
if (fc->ssl) {
|
||||||
r->schema_end = r->schema_start + 5;
|
ngx_str_set(&r->schema, "https");
|
||||||
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
r->schema_end = r->schema_start + 4;
|
ngx_str_set(&r->schema, "http");
|
||||||
}
|
}
|
||||||
|
|
||||||
value.data = ngx_pstrdup(pool, path);
|
value.data = ngx_pstrdup(pool, path);
|
||||||
@ -3477,7 +3475,7 @@ ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value)
|
|||||||
u_char c, ch;
|
u_char c, ch;
|
||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
|
|
||||||
if (r->schema_start) {
|
if (r->schema.len) {
|
||||||
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||||
"client sent duplicate :scheme header");
|
"client sent duplicate :scheme header");
|
||||||
|
|
||||||
@ -3511,8 +3509,7 @@ ngx_http_v2_parse_scheme(ngx_http_request_t *r, ngx_str_t *value)
|
|||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
r->schema_start = value->data;
|
r->schema = *value;
|
||||||
r->schema_end = value->data + value->len;
|
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
@ -3575,14 +3572,14 @@ ngx_http_v2_construct_request_line(ngx_http_request_t *r)
|
|||||||
static const u_char ending[] = " HTTP/2.0";
|
static const u_char ending[] = " HTTP/2.0";
|
||||||
|
|
||||||
if (r->method_name.len == 0
|
if (r->method_name.len == 0
|
||||||
|| r->schema_start == NULL
|
|| r->schema.len == 0
|
||||||
|| r->unparsed_uri.len == 0)
|
|| r->unparsed_uri.len == 0)
|
||||||
{
|
{
|
||||||
if (r->method_name.len == 0) {
|
if (r->method_name.len == 0) {
|
||||||
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||||
"client sent no :method header");
|
"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,
|
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
|
||||||
"client sent no :scheme header");
|
"client sent no :scheme header");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user