Browse Source

- 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
svn/tags/lighttpd-1.4.19
Elan Ruusamäe 15 years ago
parent
commit
d6b9709b54
  1. 2
      doc/configuration.txt
  2. 1
      src/array.h
  3. 4
      src/configfile-glue.c
  4. 1
      src/configparser.y
  5. 1
      src/response.c

2
doc/configuration.txt

@ -85,6 +85,8 @@ where <field> is one of one of the following:
$HTTP["cookie"]
match on cookie
$HTTP["scheme"]
match on scheme
$HTTP["host"]
match on host
$HTTP["useragent"]

1
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;

4
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;

1
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;

1
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: */

Loading…
Cancel
Save