Mercurial > hg > nginx
comparison src/http/modules/ngx_http_fastcgi_module.c @ 4329:31e6bfca10a5
FastCGI: added "if_not_empty" flag support to the "fastcgi_param" directive.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Fri, 09 Dec 2011 13:32:51 +0000 |
parents | f57229cba7ad |
children | 92deb73393f7 |
comparison
equal
deleted
inserted
replaced
4328:d15a00e6d9e6 | 4329:31e6bfca10a5 |
---|---|
409 NGX_HTTP_LOC_CONF_OFFSET, | 409 NGX_HTTP_LOC_CONF_OFFSET, |
410 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream), | 410 offsetof(ngx_http_fastcgi_loc_conf_t, upstream.next_upstream), |
411 &ngx_http_fastcgi_next_upstream_masks }, | 411 &ngx_http_fastcgi_next_upstream_masks }, |
412 | 412 |
413 { ngx_string("fastcgi_param"), | 413 { ngx_string("fastcgi_param"), |
414 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2, | 414 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE23, |
415 ngx_conf_set_keyval_slot, | 415 ngx_http_upstream_param_set_slot, |
416 NGX_HTTP_LOC_CONF_OFFSET, | 416 NGX_HTTP_LOC_CONF_OFFSET, |
417 offsetof(ngx_http_fastcgi_loc_conf_t, params_source), | 417 offsetof(ngx_http_fastcgi_loc_conf_t, params_source), |
418 NULL }, | 418 NULL }, |
419 | 419 |
420 { ngx_string("fastcgi_pass_header"), | 420 { ngx_string("fastcgi_pass_header"), |
706 { | 706 { |
707 off_t file_pos; | 707 off_t file_pos; |
708 u_char ch, *pos, *lowcase_key; | 708 u_char ch, *pos, *lowcase_key; |
709 size_t size, len, key_len, val_len, padding, | 709 size_t size, len, key_len, val_len, padding, |
710 allocated; | 710 allocated; |
711 ngx_uint_t i, n, next, hash, header_params; | 711 ngx_uint_t i, n, next, hash, skip_empty, header_params; |
712 ngx_buf_t *b; | 712 ngx_buf_t *b; |
713 ngx_chain_t *cl, *body; | 713 ngx_chain_t *cl, *body; |
714 ngx_list_part_t *part; | 714 ngx_list_part_t *part; |
715 ngx_table_elt_t *header, **ignored; | 715 ngx_table_elt_t *header, **ignored; |
716 ngx_http_script_code_pt code; | 716 ngx_http_script_code_pt code; |
737 while (*(uintptr_t *) le.ip) { | 737 while (*(uintptr_t *) le.ip) { |
738 | 738 |
739 lcode = *(ngx_http_script_len_code_pt *) le.ip; | 739 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
740 key_len = lcode(&le); | 740 key_len = lcode(&le); |
741 | 741 |
742 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
743 skip_empty = lcode(&le); | |
744 | |
742 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { | 745 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
743 lcode = *(ngx_http_script_len_code_pt *) le.ip; | 746 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
744 } | 747 } |
745 le.ip += sizeof(uintptr_t); | 748 le.ip += sizeof(uintptr_t); |
749 | |
750 if (skip_empty && val_len == 0) { | |
751 continue; | |
752 } | |
746 | 753 |
747 len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len; | 754 len += 1 + key_len + ((val_len > 127) ? 4 : 1) + val_len; |
748 } | 755 } |
749 } | 756 } |
750 | 757 |
891 while (*(uintptr_t *) le.ip) { | 898 while (*(uintptr_t *) le.ip) { |
892 | 899 |
893 lcode = *(ngx_http_script_len_code_pt *) le.ip; | 900 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
894 key_len = (u_char) lcode(&le); | 901 key_len = (u_char) lcode(&le); |
895 | 902 |
903 lcode = *(ngx_http_script_len_code_pt *) le.ip; | |
904 skip_empty = lcode(&le); | |
905 | |
896 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { | 906 for (val_len = 0; *(uintptr_t *) le.ip; val_len += lcode(&le)) { |
897 lcode = *(ngx_http_script_len_code_pt *) le.ip; | 907 lcode = *(ngx_http_script_len_code_pt *) le.ip; |
898 } | 908 } |
899 le.ip += sizeof(uintptr_t); | 909 le.ip += sizeof(uintptr_t); |
910 | |
911 if (skip_empty && val_len == 0) { | |
912 e.skip = 1; | |
913 | |
914 while (*(uintptr_t *) e.ip) { | |
915 code = *(ngx_http_script_code_pt *) e.ip; | |
916 code((ngx_http_script_engine_t *) &e); | |
917 } | |
918 e.ip += sizeof(uintptr_t); | |
919 | |
920 e.skip = 0; | |
921 | |
922 continue; | |
923 } | |
900 | 924 |
901 *e.pos++ = (u_char) key_len; | 925 *e.pos++ = (u_char) key_len; |
902 | 926 |
903 if (val_len > 127) { | 927 if (val_len > 127) { |
904 *e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80); | 928 *e.pos++ = (u_char) (((val_len >> 24) & 0x7f) | 0x80); |
2368 ngx_uint_t i, nsrc; | 2392 ngx_uint_t i, nsrc; |
2369 ngx_array_t headers_names; | 2393 ngx_array_t headers_names; |
2370 #if (NGX_HTTP_CACHE) | 2394 #if (NGX_HTTP_CACHE) |
2371 ngx_array_t params_merged; | 2395 ngx_array_t params_merged; |
2372 #endif | 2396 #endif |
2373 ngx_keyval_t *src; | |
2374 ngx_hash_key_t *hk; | 2397 ngx_hash_key_t *hk; |
2375 ngx_hash_init_t hash; | 2398 ngx_hash_init_t hash; |
2399 ngx_http_upstream_param_t *src; | |
2376 ngx_http_script_compile_t sc; | 2400 ngx_http_script_compile_t sc; |
2377 ngx_http_script_copy_code_t *copy; | 2401 ngx_http_script_copy_code_t *copy; |
2378 | 2402 |
2379 if (conf->params_source == NULL) { | 2403 if (conf->params_source == NULL) { |
2380 conf->params_source = prev->params_source; | 2404 conf->params_source = prev->params_source; |
2431 } | 2455 } |
2432 | 2456 |
2433 #if (NGX_HTTP_CACHE) | 2457 #if (NGX_HTTP_CACHE) |
2434 | 2458 |
2435 if (conf->upstream.cache) { | 2459 if (conf->upstream.cache) { |
2436 ngx_keyval_t *h, *s; | 2460 ngx_keyval_t *h; |
2437 | 2461 ngx_http_upstream_param_t *s; |
2438 if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t)) | 2462 |
2463 if (ngx_array_init(¶ms_merged, cf->temp_pool, 4, | |
2464 sizeof(ngx_http_upstream_param_t)) | |
2439 != NGX_OK) | 2465 != NGX_OK) |
2440 { | 2466 { |
2441 return NGX_ERROR; | 2467 return NGX_ERROR; |
2442 } | 2468 } |
2443 | 2469 |
2467 s = ngx_array_push(¶ms_merged); | 2493 s = ngx_array_push(¶ms_merged); |
2468 if (s == NULL) { | 2494 if (s == NULL) { |
2469 return NGX_ERROR; | 2495 return NGX_ERROR; |
2470 } | 2496 } |
2471 | 2497 |
2472 *s = *h; | 2498 s->key = h->key; |
2499 s->value = h->value; | |
2500 s->skip_empty = 0; | |
2473 | 2501 |
2474 next: | 2502 next: |
2475 | 2503 |
2476 h++; | 2504 h++; |
2477 } | 2505 } |
2508 return NGX_ERROR; | 2536 return NGX_ERROR; |
2509 } | 2537 } |
2510 | 2538 |
2511 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; | 2539 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; |
2512 copy->len = src[i].key.len; | 2540 copy->len = src[i].key.len; |
2541 | |
2542 copy = ngx_array_push_n(conf->params_len, | |
2543 sizeof(ngx_http_script_copy_code_t)); | |
2544 if (copy == NULL) { | |
2545 return NGX_ERROR; | |
2546 } | |
2547 | |
2548 copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code; | |
2549 copy->len = src[i].skip_empty; | |
2513 | 2550 |
2514 | 2551 |
2515 size = (sizeof(ngx_http_script_copy_code_t) | 2552 size = (sizeof(ngx_http_script_copy_code_t) |
2516 + src[i].key.len + sizeof(uintptr_t) - 1) | 2553 + src[i].key.len + sizeof(uintptr_t) - 1) |
2517 & ~(sizeof(uintptr_t) - 1); | 2554 & ~(sizeof(uintptr_t) - 1); |