<div dir="ltr">Hi.<div><br></div><div><div>diff -r 8e6bb4e6045f src/http/ngx_http_variables.c</div><div>--- a/src/http/ngx_http_variables.c<span style="white-space:pre">     </span>Thu Jun 07 20:04:22 2018 +0300</div><div>+++ b/src/http/ngx_http_variables.c<span style="white-space:pre">     </span>Thu Jun 07 12:20:05 2018 -0400</div><div>@@ -1420,25 +1420,11 @@</div><div> ngx_http_variable_scheme(ngx_http_request_t *r,</div><div>     ngx_http_variable_value_t *v, uintptr_t data)</div><div> {</div><div>-#if (NGX_HTTP_SSL)</div><div>-</div><div>-    if (r->connection->ssl) {</div><div>-        v->len = sizeof("https") - 1;</div><div>-        v->valid = 1;</div><div>-        v->no_cacheable = 0;</div><div>-        v->not_found = 0;</div><div>-        v->data = (u_char *) "https";</div><div>-</div><div>-        return NGX_OK;</div><div>-    }</div><div>-</div><div>-#endif</div><div>-</div><div>-    v->len = sizeof("http") - 1;</div><div>     v->valid = 1;</div><div>     v->no_cacheable = 0;</div><div>     v->not_found = 0;</div><div>-    v->data = (u_char *) "http";</div><div>+    v->len = r->schema.len;</div><div>+    v->data = r->schema.data;</div><div><br></div><div>     return NGX_OK;</div><div> }</div></div><div><br></div><div>Thanks.</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jun 8, 2018 at 3:01 AM Ruslan Ermilov <<a href="mailto:ru@nginx.com">ru@nginx.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">details:   <a href="http://hg.nginx.org/nginx/rev/89430899c72a" rel="noreferrer" target="_blank">http://hg.nginx.org/nginx/rev/89430899c72a</a><br>
branches:  <br>
changeset: 7295:89430899c72a<br>
user:      Ruslan Ermilov <<a href="mailto:ru@nginx.com" target="_blank">ru@nginx.com</a>><br>
date:      Thu Jun 07 20:01:41 2018 +0300<br>
description:<br>
Added r->schema.<br>
<br>
For HTTP/1, it keeps scheme from the absolute form of URI.<br>
For HTTP/2, the :scheme request pseudo-header field value.<br>
<br>
diffstat:<br>
<br>
 src/http/ngx_http_core_module.c |   1 +<br>
 src/http/ngx_http_request.c     |   5 +++++<br>
 src/http/ngx_http_request.h     |   1 +<br>
 src/http/v2/ngx_http_v2.c       |  15 ++++++---------<br>
 4 files changed, 13 insertions(+), 9 deletions(-)<br>
<br>
diffs (95 lines):<br>
<br>
diff -r 21ad2af3262c -r 89430899c72a src/http/ngx_http_core_module.c<br>
--- a/src/http/ngx_http_core_module.c   Thu Jun 07 19:53:43 2018 +0300<br>
+++ b/src/http/ngx_http_core_module.c   Thu Jun 07 20:01:41 2018 +0300<br>
@@ -2318,6 +2318,7 @@ ngx_http_subrequest(ngx_http_request_t *<br>
     sr->unparsed_uri = r->unparsed_uri;<br>
     sr->method_name = ngx_http_core_get_method;<br>
     sr->http_protocol = r->http_protocol;<br>
+    sr->schema = r->schema;<br>
<br>
     ngx_http_set_exten(sr);<br>
<br>
diff -r 21ad2af3262c -r 89430899c72a src/http/ngx_http_request.c<br>
--- a/src/http/ngx_http_request.c       Thu Jun 07 19:53:43 2018 +0300<br>
+++ b/src/http/ngx_http_request.c       Thu Jun 07 20:01:41 2018 +0300<br>
@@ -987,6 +987,11 @@ ngx_http_process_request_line(ngx_event_<br>
                 return;<br>
             }<br>
<br>
+            if (r->schema_end) {<br>
+                r->schema.len = r->schema_end - r->schema_start;<br>
+                r->schema.data = r->schema_start;<br>
+            }<br>
+<br>
             if (r->host_end) {<br>
<br>
                 host.len = r->host_end - r->host_start;<br>
diff -r 21ad2af3262c -r 89430899c72a src/http/ngx_http_request.h<br>
--- a/src/http/ngx_http_request.h       Thu Jun 07 19:53:43 2018 +0300<br>
+++ b/src/http/ngx_http_request.h       Thu Jun 07 20:01:41 2018 +0300<br>
@@ -412,6 +412,7 @@ struct ngx_http_request_s {<br>
<br>
     ngx_str_t                         method_name;<br>
     ngx_str_t                         http_protocol;<br>
+    ngx_str_t                         schema;<br>
<br>
     ngx_chain_t                      *out;<br>
     ngx_http_request_t               *main;<br>
diff -r 21ad2af3262c -r 89430899c72a src/http/v2/ngx_http_v2.c<br>
--- a/src/http/v2/ngx_http_v2.c Thu Jun 07 19:53:43 2018 +0300<br>
+++ b/src/http/v2/ngx_http_v2.c Thu Jun 07 20:01:41 2018 +0300<br>
@@ -2616,16 +2616,14 @@ ngx_http_v2_push_stream(ngx_http_v2_stre<br>
     r->method_name = ngx_http_core_get_method;<br>
     r->method = NGX_HTTP_GET;<br>
<br>
-    r->schema_start = (u_char *) "https";<br>
-<br>
 #if (NGX_HTTP_SSL)<br>
     if (fc->ssl) {<br>
-        r->schema_end = r->schema_start + 5;<br>
+        ngx_str_set(&r->schema, "https");<br>
<br>
     } else<br>
 #endif<br>
     {<br>
-        r->schema_end = r->schema_start + 4;<br>
+        ngx_str_set(&r->schema, "http");<br>
     }<br>
<br>
     value.data = ngx_pstrdup(pool, path);<br>
@@ -3477,7 +3475,7 @@ ngx_http_v2_parse_scheme(ngx_http_reques<br>
     u_char      c, ch;<br>
     ngx_uint_t  i;<br>
<br>
-    if (r->schema_start) {<br>
+    if (r->schema.len) {<br>
         ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,<br>
                       "client sent duplicate :scheme header");<br>
<br>
@@ -3511,8 +3509,7 @@ ngx_http_v2_parse_scheme(ngx_http_reques<br>
         return NGX_DECLINED;<br>
     }<br>
<br>
-    r->schema_start = value->data;<br>
-    r->schema_end = value->data + value->len;<br>
+    r->schema = *value;<br>
<br>
     return NGX_OK;<br>
 }<br>
@@ -3575,14 +3572,14 @@ ngx_http_v2_construct_request_line(ngx_h<br>
     static const u_char ending[] = " HTTP/2.0";<br>
<br>
     if (r->method_name.len == 0<br>
-        || r->schema_start == NULL<br>
+        || r->schema.len == 0<br>
         || r->unparsed_uri.len == 0)<br>
     {<br>
         if (r->method_name.len == 0) {<br>
             ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,<br>
                           "client sent no :method header");<br>
<br>
-        } else if (r->schema_start == NULL) {<br>
+        } else if (r->schema.len == 0) {<br>
             ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,<br>
                           "client sent no :scheme header");<br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org" target="_blank">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</blockquote></div>