| 
 |   
| version 1.1, 2013/10/14 10:32:48 | version 1.1.1.3, 2016/11/02 10:35:00 | 
|---|---|
| Line 1 | Line 1 | 
| #include "first.h" | |
| #include "plugin.h" | #include "plugin.h" | 
| #include "log.h" | #include "log.h" | 
| #include "response.h" | #include "response.h" | 
| Line 46 FREE_FUNC(mod_evhost_free) { | Line 48 FREE_FUNC(mod_evhost_free) { | 
| for (i = 0; i < srv->config_context->used; i++) { | for (i = 0; i < srv->config_context->used; i++) { | 
| plugin_config *s = p->config_storage[i]; | plugin_config *s = p->config_storage[i]; | 
| if (!s) continue; | if (NULL == s) continue; | 
| if(s->path_pieces) { | if(s->path_pieces) { | 
| size_t j; | size_t j; | 
| Line 128 SETDEFAULTS_FUNC(mod_evhost_set_defaults) { | Line 130 SETDEFAULTS_FUNC(mod_evhost_set_defaults) { | 
| if (!p) return HANDLER_ERROR; | if (!p) return HANDLER_ERROR; | 
| p->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *)); | p->config_storage = calloc(1, srv->config_context->used * sizeof(plugin_config *)); | 
| for (i = 0; i < srv->config_context->used; i++) { | for (i = 0; i < srv->config_context->used; i++) { | 
| data_config const* config = (data_config const*)srv->config_context->data[i]; | |
| plugin_config *s; | plugin_config *s; | 
| s = calloc(1, sizeof(plugin_config)); | s = calloc(1, sizeof(plugin_config)); | 
| Line 142 SETDEFAULTS_FUNC(mod_evhost_set_defaults) { | Line 145 SETDEFAULTS_FUNC(mod_evhost_set_defaults) { | 
| p->config_storage[i] = s; | p->config_storage[i] = s; | 
| if (0 != config_insert_values_global(srv, ((data_config *)srv->config_context->data[i])->value, cv)) { | if (0 != config_insert_values_global(srv, config->value, cv, i == 0 ? T_CONFIG_SCOPE_SERVER : T_CONFIG_SCOPE_CONNECTION)) { | 
| return HANDLER_ERROR; | return HANDLER_ERROR; | 
| } | } | 
| if (s->path_pieces_raw->used != 0) { | if (!buffer_string_is_empty(s->path_pieces_raw)) { | 
| mod_evhost_parse_pattern(s); | mod_evhost_parse_pattern(s); | 
| } | } | 
| } | } | 
| Line 164 SETDEFAULTS_FUNC(mod_evhost_set_defaults) { | Line 167 SETDEFAULTS_FUNC(mod_evhost_set_defaults) { | 
| */ | */ | 
| static int mod_evhost_parse_host(connection *con,array *host) { | static int mod_evhost_parse_host(connection *con,array *host) { | 
| /* con->uri.authority->used is always > 0 if we come here */ | register char *ptr = con->uri.authority->ptr + buffer_string_length(con->uri.authority); | 
| register char *ptr = con->uri.authority->ptr + con->uri.authority->used - 1; | |
| char *colon = ptr; /* needed to filter out the colon (if exists) */ | char *colon = ptr; /* needed to filter out the colon (if exists) */ | 
| int first = 1; | int first = 1; | 
| data_string *ds; | data_string *ds; | 
| Line 200 static int mod_evhost_parse_host(connection *con,array | Line 202 static int mod_evhost_parse_host(connection *con,array | 
| /* is something between the dots */ | /* is something between the dots */ | 
| ds = data_string_init(); | ds = data_string_init(); | 
| buffer_copy_string_len(ds->key,CONST_STR_LEN("%")); | buffer_copy_string_len(ds->key,CONST_STR_LEN("%")); | 
| buffer_append_long(ds->key, i++); | buffer_append_int(ds->key, i++); | 
| buffer_copy_string_len(ds->value,ptr+1,colon-ptr-1); | buffer_copy_string_len(ds->value,ptr+1,colon-ptr-1); | 
| array_insert_unique(host,(data_unset *)ds); | array_insert_unique(host,(data_unset *)ds); | 
| Line 213 static int mod_evhost_parse_host(connection *con,array | Line 215 static int mod_evhost_parse_host(connection *con,array | 
| if (colon != ptr) { | if (colon != ptr) { | 
| ds = data_string_init(); | ds = data_string_init(); | 
| buffer_copy_string_len(ds->key,CONST_STR_LEN("%")); | buffer_copy_string_len(ds->key,CONST_STR_LEN("%")); | 
| buffer_append_long(ds->key, i /* ++ */); | buffer_append_int(ds->key, i /* ++ */); | 
| buffer_copy_string_len(ds->value,ptr,colon-ptr); | buffer_copy_string_len(ds->value,ptr,colon-ptr); | 
| array_insert_unique(host,(data_unset *)ds); | array_insert_unique(host,(data_unset *)ds); | 
| Line 265 static handler_t mod_evhost_uri_handler(server *srv, c | Line 267 static handler_t mod_evhost_uri_handler(server *srv, c | 
| stat_cache_entry *sce = NULL; | stat_cache_entry *sce = NULL; | 
| /* not authority set */ | /* not authority set */ | 
| if (con->uri.authority->used == 0) return HANDLER_GO_ON; | if (buffer_string_is_empty(con->uri.authority)) return HANDLER_GO_ON; | 
| mod_evhost_patch_connection(srv, con, p); | mod_evhost_patch_connection(srv, con, p); | 
| Line 300 static handler_t mod_evhost_uri_handler(server *srv, c | Line 302 static handler_t mod_evhost_uri_handler(server *srv, c | 
| buffer_append_string_len(p->tmp_buf, con->uri.authority->ptr, colon - con->uri.authority->ptr); /* adds fqdn */ | 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))) { | } 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); | 
| buffer_append_string_buffer(p->tmp_buf,ds->value); | |
| } | |
| } else { | } else { | 
| /* unhandled %-sequence */ | /* unhandled %-sequence */ | 
| } | } | 
| Line 311 static handler_t mod_evhost_uri_handler(server *srv, c | Line 311 static handler_t mod_evhost_uri_handler(server *srv, c | 
| } | } | 
| } | } | 
| BUFFER_APPEND_SLASH(p->tmp_buf); | buffer_append_slash(p->tmp_buf); | 
| array_free(parsed_host); | array_free(parsed_host); | 
| Line 324 static handler_t mod_evhost_uri_handler(server *srv, c | Line 324 static handler_t mod_evhost_uri_handler(server *srv, c | 
| } | } | 
| if (!not_good) { | if (!not_good) { | 
| buffer_copy_string_buffer(con->physical.doc_root, p->tmp_buf); | buffer_copy_buffer(con->physical.doc_root, p->tmp_buf); | 
| } | } | 
| return HANDLER_GO_ON; | return HANDLER_GO_ON; |