Browse Source

Add '%_' pattern for complete hostname in mod_evhost (fixes #1737)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2483 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.23
Stefan Bühler 13 years ago
parent
commit
0544f34ee3
  1. 1
      NEWS
  2. 1
      doc/evhost.txt
  3. 20
      src/mod_evhost.c

1
NEWS

@ -31,6 +31,7 @@ NEWS
* Limit amount of bytes read for one read-event (fixes #1070)
* Add evasive.silent option (fixes #1438)
* Make mod_extforward headers configurable (fixes #1545)
* Add '%_' pattern for complete hostname in mod_evhost (fixes #1737)
- 1.4.22 - 2009-03-07
* Fix wrong lua type for CACHE_MISS/CACHE_HIT in mod_cml (fixes #533)

1
doc/evhost.txt

@ -33,6 +33,7 @@ wildcards. Those wildcards can represent parts if the submitted hostname
%2 => domain name without tld
%3 => subdomain 1 name
%4 => subdomain 2 name
%_ => the complete hostname (without port info)
evhost.path-pattern = "/home/www/servers/%3/pages/"

20
src/mod_evhost.c

@ -115,6 +115,7 @@ SETDEFAULTS_FUNC(mod_evhost_set_defaults) {
* # %2 => domain name without tld
* # %3 => subdomain 1 name
* # %4 => subdomain 2 name
* # %_ => fqdn (without port info)
* #
* evhost.path-pattern = "/home/ckruse/dev/www/%3/htdocs/"
*
@ -154,11 +155,12 @@ SETDEFAULTS_FUNC(mod_evhost_set_defaults) {
}
/**
* assign the different parts of the domain to array-indezes
* - %0 - full hostname (authority w/o port)
* assign the different parts of the domain to array-indezes (sub2.sub1.domain.tld)
* - %0 - domain.tld
* - %1 - tld
* - %2 - domain.tld
* - %3 -
* - %2 - domain
* - %3 - sub1
* - ...
*/
static int mod_evhost_parse_host(connection *con,array *host) {
@ -287,6 +289,16 @@ static handler_t mod_evhost_uri_handler(server *srv, connection *con, void *p_d)
if (*(ptr+1) == '%') {
/* %% */
buffer_append_string_len(p->tmp_buf,CONST_STR_LEN("%"));
} else if (*(ptr+1) == '_' ) {
/* %_ == full hostname */
char *colon = strchr(con->uri.authority->ptr, ':');
if(colon == NULL) {
buffer_append_string_buffer(p->tmp_buf, con->uri.authority); // adds fqdn
} else {
/* strip the port out of the authority-part of the URI scheme */
buffer_append_string_len(p->tmp_buf, con->uri.authority->ptr, colon - con->uri.authority->ptr); // adds fqdn
}
} else if (NULL != (ds = (data_string *)array_get_element(parsed_host,p->conf.path_pieces[i]->ptr))) {
if (ds->value->used) {
buffer_append_string_buffer(p->tmp_buf,ds->value);

Loading…
Cancel
Save