aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2011-12-09 13:32:51 +0000
committerValentin Bartenev <vbart@nginx.com>2011-12-09 13:32:51 +0000
commita826eb672076aa1bc8469dedb4a97afc3009ca20 (patch)
tree25cb97e9400ae3fc2549caa3ff573c3957b2fcdd /src
parent50546b26d9ce3519907e7c341ad6ccecc1b4bab0 (diff)
downloadnginx-a826eb672076aa1bc8469dedb4a97afc3009ca20.tar.gz
nginx-a826eb672076aa1bc8469dedb4a97afc3009ca20.zip
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
Diffstat (limited to 'src')
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c51
1 files changed, 44 insertions, 7 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 2dc56c76b..599edc77c 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -411,8 +411,8 @@ static ngx_command_t ngx_http_fastcgi_commands[] = {
&ngx_http_fastcgi_next_upstream_masks },
{ ngx_string("fastcgi_param"),
- NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
- ngx_conf_set_keyval_slot,
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23,
+ ngx_http_upstream_param_set_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_fastcgi_loc_conf_t, params_source),
NULL },
@@ -708,7 +708,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
u_char ch, *pos, *lowcase_key;
size_t size, len, key_len, val_len, padding,
allocated;
- ngx_uint_t i, n, next, hash, header_params;
+ ngx_uint_t i, n, next, hash, skip_empty, header_params;
ngx_buf_t *b;
ngx_chain_t *cl, *body;
ngx_list_part_t *part;
@@ -739,11 +739,18 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
lcode = *(ngx_http_script_len_code_pt *) le.ip;
key_len = lcode(&le);
+ lcode = *(ngx_http_script_len_code_pt *) le.ip;
+ skip_empty = lcode(&le);
+
for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
lcode = *(ngx_http_script_len_code_pt *) le.ip;
}
le.ip += sizeof(uintptr_t);
+ if (skip_empty && val_len == 0) {
+ continue;
+ }
+
len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len;
}
}
@@ -893,11 +900,28 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
lcode = *(ngx_http_script_len_code_pt *) le.ip;
key_len = (u_char) lcode(&le);
+ lcode = *(ngx_http_script_len_code_pt *) le.ip;
+ skip_empty = lcode(&le);
+
for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) {
lcode = *(ngx_http_script_len_code_pt *) le.ip;
}
le.ip += sizeof(uintptr_t);
+ if (skip_empty && val_len == 0) {
+ e.skip = 1;
+
+ while (*(uintptr_t *) e.ip) {
+ code = *(ngx_http_script_code_pt *) e.ip;
+ code((ngx_http_script_engine_t *) &e);
+ }
+ e.ip += sizeof(uintptr_t);
+
+ e.skip = 0;
+
+ continue;
+ }
+
*e.pos++ = (u_char) key_len;
if (val_len > 127) {
@@ -2370,9 +2394,9 @@ ngx_http_fastcgi_merge_params(ngx_conf_t *cf,
#if (NGX_HTTP_CACHE)
ngx_array_t params_merged;
#endif
- ngx_keyval_t *src;
ngx_hash_key_t *hk;
ngx_hash_init_t hash;
+ ngx_http_upstream_param_t *src;
ngx_http_script_compile_t sc;
ngx_http_script_copy_code_t *copy;
@@ -2433,9 +2457,11 @@ ngx_http_fastcgi_merge_params(ngx_conf_t *cf,
#if (NGX_HTTP_CACHE)
if (conf->upstream.cache) {
- ngx_keyval_t *h, *s;
+ ngx_keyval_t *h;
+ ngx_http_upstream_param_t *s;
- if (ngx_array_init(&params_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t))
+ if (ngx_array_init(&params_merged, cf->temp_pool, 4,
+ sizeof(ngx_http_upstream_param_t))
!= NGX_OK)
{
return NGX_ERROR;
@@ -2469,7 +2495,9 @@ ngx_http_fastcgi_merge_params(ngx_conf_t *cf,
return NGX_ERROR;
}
- *s = *h;
+ s->key = h->key;
+ s->value = h->value;
+ s->skip_empty = 0;
next:
@@ -2511,6 +2539,15 @@ ngx_http_fastcgi_merge_params(ngx_conf_t *cf,
copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
+ copy = ngx_array_push_n(conf->params_len,
+ sizeof(ngx_http_script_copy_code_t));
+ if (copy == NULL) {
+ return NGX_ERROR;
+ }
+
+ copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
+ copy->len = src[i].skip_empty;
+
size = (sizeof(ngx_http_script_copy_code_t)
+ src[i].key.len + sizeof(uintptr_t) - 1)