comparison src/http/modules/ngx_http_map_module.c @ 3790:d8300807c4f3

allow empty value as "map" parameter
author Igor Sysoev <igor@sysoev.ru>
date Thu, 25 Nov 2010 15:24:29 +0000
parents 19c931be8b98
children 11701c4c0358
comparison
equal deleted inserted replaced
3789:19c931be8b98 3790:d8300807c4f3
120 120
121 if (len && map->hostnames && val.data[len - 1] == '.') { 121 if (len && map->hostnames && val.data[len - 1] == '.') {
122 len--; 122 len--;
123 } 123 }
124 124
125 if (len == 0) {
126 *v = *map->default_value;
127 return NGX_OK;
128 }
129
130 key = ngx_hash_strlow(val.data, val.data, len); 125 key = ngx_hash_strlow(val.data, val.data, len);
131 126
132 value = ngx_hash_find_combined(&map->hash, key, val.data, len); 127 value = ngx_hash_find_combined(&map->hash, key, val.data, len);
133 128
134 if (value) { 129 if (value) {
355 350
356 } else if (cf->args->nelts != 2) { 351 } else if (cf->args->nelts != 2) {
357 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 352 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
358 "invalid number of the map parameters"); 353 "invalid number of the map parameters");
359 return NGX_CONF_ERROR; 354 return NGX_CONF_ERROR;
360
361 } else if (value[0].len == 0) {
362 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
363 "invalid first parameter");
364 return NGX_CONF_ERROR;
365 } 355 }
366 356
367 if (ngx_strcmp(value[0].data, "include") == 0) { 357 if (ngx_strcmp(value[0].data, "include") == 0) {
368 file = value[1]; 358 file = value[1];
369 359