[PATCH] HTTP/2: Make $scheme variable return :scheme pseudo-header value

Chris Branch cbranch at cloudflare.com
Wed Feb 22 14:30:21 UTC 2017


# HG changeset patch
# User Chris Branch <cbranch at cloudflare.com>
# Date 1487773385 0
#      Wed Feb 22 14:23:05 2017 +0000
# Node ID 2d050c8c2e688c26f4796a09c728c85678c611b4
# Parent  87cf6ddb41c216876d13cffa5e637a61b159362c
HTTP/2: Make $scheme variable return :scheme pseudo-header value.

This is relevant for plaintext HTTP/2 as well as HTTP/2 over TLS using
opportunistic security, as described in:
https://tools.ietf.org/html/draft-ietf-httpbis-http2-encryption

diff -r 87cf6ddb41c2 -r 2d050c8c2e68 src/http/ngx_http_variables.c
--- a/src/http/ngx_http_variables.c	Fri Feb 17 17:01:27 2017 +0300
+++ b/src/http/ngx_http_variables.c	Wed Feb 22 14:23:05 2017 +0000
@@ -1386,6 +1386,16 @@
 ngx_http_variable_scheme(ngx_http_request_t *r,
     ngx_http_variable_value_t *v, uintptr_t data)
 {
+    if (r->schema_start) {
+        v->len = r->schema_end - r->schema_start;
+        v->valid = 1;
+        v->no_cacheable = 0;
+        v->not_found = 0;
+        v->data = r->schema_start;
+
+        return NGX_OK;
+    }
+
 #if (NGX_HTTP_SSL)
 
     if (r->connection->ssl) {


More information about the nginx-devel mailing list