Welcome! Log In Create A New Profile

Advanced

[nginx] Added r->schema.

June 07, 2018 03:04PM
details: http://hg.nginx.org/nginx/rev/89430899c72a
branches:
changeset: 7295:89430899c72a
user: Ruslan Ermilov <ru@nginx.com>
date: Thu Jun 07 20:01:41 2018 +0300
description:
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.

diffstat:

src/http/ngx_http_core_module.c | 1 +
src/http/ngx_http_request.c | 5 +++++
src/http/ngx_http_request.h | 1 +
src/http/v2/ngx_http_v2.c | 15 ++++++---------
4 files changed, 13 insertions(+), 9 deletions(-)

diffs (95 lines):

diff -r 21ad2af3262c -r 89430899c72a src/http/ngx_http_core_module.c
--- 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 @@ ngx_http_subrequest(ngx_http_request_t *
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 -r 21ad2af3262c -r 89430899c72a src/http/ngx_http_request.c
--- 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 @@ ngx_http_process_request_line(ngx_event_
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 -r 21ad2af3262c -r 89430899c72a src/http/ngx_http_request.h
--- 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 @@ struct ngx_http_request_s {

ngx_str_t method_name;
ngx_str_t http_protocol;
+ ngx_str_t schema;

ngx_chain_t *out;
ngx_http_request_t *main;
diff -r 21ad2af3262c -r 89430899c72a src/http/v2/ngx_http_v2.c
--- 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 @@ ngx_http_v2_push_stream(ngx_http_v2_stre
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 @@ ngx_http_v2_parse_scheme(ngx_http_reques
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 @@ ngx_http_v2_parse_scheme(ngx_http_reques
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 @@ ngx_http_v2_construct_request_line(ngx_h
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");

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Added r->schema.

ru@nginx.com 790 June 07, 2018 03:04PM

Re: [nginx] Added r->schema.

karton 407 June 07, 2018 11:30PM

Re: [nginx] Added r->schema.

ru@nginx.com 524 June 08, 2018 04:02AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 245
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready