From d6b9709b548d7a25824fb34161000dfcd9a81e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Sun, 4 Nov 2007 16:53:17 +0000 Subject: [PATCH] - support for matching $HTTP["scheme"] in configs, patch from: http://trac.lighttpd.net/trac/wiki/HowToRedirectHttpToHttps apparently by swiergot/at/gmail.com, adjusted for current svn. git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2012 152afb58-edef-0310-8abb-c4023f1b3aa9 --- doc/configuration.txt | 2 ++ src/array.h | 1 + src/configfile-glue.c | 4 ++++ src/configparser.y | 1 + src/response.c | 1 + 5 files changed, 9 insertions(+) diff --git a/doc/configuration.txt b/doc/configuration.txt index 9ed458f2..29480cb3 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -85,6 +85,8 @@ where is one of one of the following: $HTTP["cookie"] match on cookie +$HTTP["scheme"] + match on scheme $HTTP["host"] match on host $HTTP["useragent"] diff --git a/src/array.h b/src/array.h index b8a83455..3a5b05f0 100644 --- a/src/array.h +++ b/src/array.h @@ -90,6 +90,7 @@ typedef enum { COMP_HTTP_COOKIE, COMP_HTTP_REMOTEIP, COMP_HTTP_QUERYSTRING, + COMP_HTTP_SCHEME, COMP_LAST_ELEMENT } comp_key_t; diff --git a/src/configfile-glue.c b/src/configfile-glue.c index f6ead924..df8d1b11 100644 --- a/src/configfile-glue.c +++ b/src/configfile-glue.c @@ -341,6 +341,10 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat } break; } + case COMP_HTTP_SCHEME: + l = con->uri.scheme; + break; + case COMP_HTTP_URL: l = con->uri.path; break; diff --git a/src/configparser.y b/src/configparser.y index 30f5fd91..18aa22bf 100644 --- a/src/configparser.y +++ b/src/configparser.y @@ -422,6 +422,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio { COMP_HTTP_COOKIE, CONST_STR_LEN("HTTP[\"cookie\"]" ) }, { COMP_HTTP_REMOTEIP, CONST_STR_LEN("HTTP[\"remoteip\"]" ) }, { COMP_HTTP_QUERYSTRING, CONST_STR_LEN("HTTP[\"querystring\"]") }, + { COMP_HTTP_SCHEME, CONST_STR_LEN("HTTP[\"scheme\"]" ) }, { COMP_UNSET, NULL, 0 }, }; size_t i; diff --git a/src/response.c b/src/response.c index b8775f06..93c3839d 100644 --- a/src/response.c +++ b/src/response.c @@ -180,6 +180,7 @@ handler_t http_response_prepare(server *srv, connection *con) { buffer_copy_string_buffer(con->uri.authority, con->request.http_host); buffer_to_lower(con->uri.authority); + config_patch_connection(srv, con, COMP_HTTP_SCHEME); /* Scheme: */ config_patch_connection(srv, con, COMP_HTTP_HOST); /* Host: */ config_patch_connection(srv, con, COMP_HTTP_REMOTEIP); /* Client-IP */ config_patch_connection(srv, con, COMP_HTTP_REFERER); /* Referer: */