Added Language conditional (fixes #1119); patch by petar

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2392 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.21
Stefan Bühler 2009-02-05 22:36:58 +00:00
parent 83e2296c02
commit 066b208bb6
6 changed files with 21 additions and 0 deletions

1
NEWS
View File

@ -37,6 +37,7 @@ NEWS
* Fix error handling in freebsd-sendfile (fixes #1813)
* Silenced the annoying "request timed out" warning, enable with the "debug.log-timeouts" option (fixes #1529)
* Allow tabs in header values (fixes #1822)
* Added Language conditional (fixes #1119); patch by petar
- 1.4.20 - 2008-09-30

View File

@ -90,13 +90,21 @@ $HTTP["scheme"]
$HTTP["host"]
match on host
$HTTP["useragent"]
$HTTP["user-agent"]
match on useragent
$HTTP["referer"]
match on referer
$HTTP["method"]
math on the http method
$HTTP["url"]
match on url
$HTTP["query-string"]
match on the (not decoded) query-string
$HTTP["remoteip"]
$HTTP["remote-ip"]
match on the remote IP or a remote Network
$HTTP["language"]
match on the Accept-Language header
$SERVER["socket"]
match on socket. Value must be on the format "ip:port" where ip is an IP
address and port a port number. Only equal match (==) is supported.

View File

@ -87,6 +87,7 @@ typedef enum {
COMP_HTTP_HOST,
COMP_HTTP_REFERER,
COMP_HTTP_USER_AGENT,
COMP_HTTP_LANGUAGE,
COMP_HTTP_COOKIE,
COMP_HTTP_REMOTE_IP,
COMP_HTTP_QUERY_STRING,

View File

@ -413,6 +413,15 @@ static cond_result_t config_check_cond_nocache(server *srv, connection *con, dat
break;
}
case COMP_HTTP_LANGUAGE: {
data_string *ds;
if (NULL != (ds = (data_string *)array_get_element(con->request.headers, "Accept-Language"))) {
l = ds->value;
} else {
l = srv->empty_string;
}
break;
}
default:
return COND_RESULT_FALSE;
}

View File

@ -427,6 +427,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio
{ COMP_HTTP_REFERER, CONST_STR_LEN("HTTP[\"referer\"]" ) },
{ COMP_HTTP_USER_AGENT, CONST_STR_LEN("HTTP[\"useragent\"]" ) },
{ COMP_HTTP_USER_AGENT, CONST_STR_LEN("HTTP[\"user-agent\"]" ) },
{ COMP_HTTP_LANGUAGE, CONST_STR_LEN("HTTP[\"language\"]" ) },
{ COMP_HTTP_COOKIE, CONST_STR_LEN("HTTP[\"cookie\"]" ) },
{ COMP_HTTP_REMOTE_IP, CONST_STR_LEN("HTTP[\"remoteip\"]" ) },
{ COMP_HTTP_REMOTE_IP, CONST_STR_LEN("HTTP[\"remote-ip\"]" ) },

View File

@ -198,6 +198,7 @@ handler_t http_response_prepare(server *srv, connection *con) {
config_patch_connection(srv, con, COMP_HTTP_REMOTE_IP); /* Client-IP */
config_patch_connection(srv, con, COMP_HTTP_REFERER); /* Referer: */
config_patch_connection(srv, con, COMP_HTTP_USER_AGENT);/* User-Agent: */
config_patch_connection(srv, con, COMP_HTTP_LANGUAGE); /* Accept-Language: */
config_patch_connection(srv, con, COMP_HTTP_COOKIE); /* Cookie: */
config_patch_connection(srv, con, COMP_HTTP_REQUEST_METHOD); /* REQUEST_METHOD */