Mercurial > hg > nginx
comparison src/http/modules/ngx_http_map_module.c @ 4712:fd3eefefa5f9
map: strip final dot before looking up in a map of hostnames.
(closes #182)
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Fri, 29 Jun 2012 20:33:26 +0000 |
parents | d620f497c50f |
children | 0656cfe8f7cb |
comparison
equal
deleted
inserted
replaced
4709:7f8d224d3bfb | 4712:fd3eefefa5f9 |
---|---|
108 ngx_http_map_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, | 108 ngx_http_map_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
109 uintptr_t data) | 109 uintptr_t data) |
110 { | 110 { |
111 ngx_http_map_ctx_t *map = (ngx_http_map_ctx_t *) data; | 111 ngx_http_map_ctx_t *map = (ngx_http_map_ctx_t *) data; |
112 | 112 |
113 size_t len; | |
114 ngx_str_t val; | 113 ngx_str_t val; |
115 ngx_http_variable_value_t *value; | 114 ngx_http_variable_value_t *value; |
116 | 115 |
117 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 116 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
118 "http map started"); | 117 "http map started"); |
119 | 118 |
120 if (ngx_http_complex_value(r, &map->value, &val) != NGX_OK) { | 119 if (ngx_http_complex_value(r, &map->value, &val) != NGX_OK) { |
121 return NGX_ERROR; | 120 return NGX_ERROR; |
122 } | 121 } |
123 | 122 |
124 len = val.len; | 123 if (map->hostnames && val.len > 0 && val.data[val.len - 1] == '.') { |
125 | 124 val.len--; |
126 if (len && map->hostnames && val.data[len - 1] == '.') { | |
127 len--; | |
128 } | 125 } |
129 | 126 |
130 value = ngx_http_map_find(r, &map->map, &val); | 127 value = ngx_http_map_find(r, &map->map, &val); |
131 | 128 |
132 if (value == NULL) { | 129 if (value == NULL) { |
279 } | 276 } |
280 | 277 |
281 map->default_value = ctx.default_value ? ctx.default_value: | 278 map->default_value = ctx.default_value ? ctx.default_value: |
282 &ngx_http_variable_null_value; | 279 &ngx_http_variable_null_value; |
283 | 280 |
281 map->hostnames = ctx.hostnames; | |
282 | |
284 hash.key = ngx_hash_key_lc; | 283 hash.key = ngx_hash_key_lc; |
285 hash.max_size = mcf->hash_max_size; | 284 hash.max_size = mcf->hash_max_size; |
286 hash.bucket_size = mcf->hash_bucket_size; | 285 hash.bucket_size = mcf->hash_bucket_size; |
287 hash.name = "map_hash"; | 286 hash.name = "map_hash"; |
288 hash.pool = cf->pool; | 287 hash.pool = cf->pool; |