aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_proxy_module.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2007-12-09 18:03:20 +0000
committerIgor Sysoev <igor@sysoev.ru>2007-12-09 18:03:20 +0000
commitcb540618856bf0f45d0228f34279a57bd0cc6796 (patch)
tree3e54501c8c5ae7f68a65a5d597991cf788c9e2d7 /src/http/modules/ngx_http_proxy_module.c
parentd8c43746a509fc0e45e3f6668aadb2237e39979c (diff)
downloadnginx-cb540618856bf0f45d0228f34279a57bd0cc6796.tar.gz
nginx-cb540618856bf0f45d0228f34279a57bd0cc6796.zip
*) now ngx_conf_set_str_array_slot() tests NGX_CONF_UNSET_PTR
this fixes fastcgi_catch_stderr segfault introduced in r1453 *) ngx_http_upstream_hide_headers_hash() *) proxy/fastcgi pass_header/hide_header use ngx_http_upstream_hide_headers_hash()
Diffstat (limited to 'src/http/modules/ngx_http_proxy_module.c')
-rw-r--r--src/http/modules/ngx_http_proxy_module.c108
1 files changed, 9 insertions, 99 deletions
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index 24da70dcc..ec31673ad 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -1634,8 +1634,6 @@ ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
* conf->upstream.next_upstream = 0;
* conf->upstream.temp_path = NULL;
* conf->upstream.hide_headers_hash = { NULL, 0 };
- * conf->upstream.hide_headers = NULL;
- * conf->upstream.pass_headers = NULL;
* conf->upstream.schema = { 0, NULL };
* conf->upstream.uri = { 0, NULL };
* conf->upstream.location = NULL;
@@ -1672,6 +1670,9 @@ ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
conf->upstream.pass_request_headers = NGX_CONF_UNSET;
conf->upstream.pass_request_body = NGX_CONF_UNSET;
+ conf->upstream.hide_headers = NGX_CONF_UNSET_PTR;
+ conf->upstream.pass_headers = NGX_CONF_UNSET_PTR;
+
conf->upstream.intercept_errors = NGX_CONF_UNSET;
/* "proxy_cyclic_temp_file" is disabled */
@@ -1696,9 +1697,7 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
u_char *p;
size_t size;
uintptr_t *code;
- ngx_str_t *header;
- ngx_uint_t i, j;
- ngx_array_t hide_headers;
+ ngx_uint_t i;
ngx_keyval_t *src, *s, *h;
ngx_hash_key_t *hk;
ngx_hash_init_t hash;
@@ -1913,107 +1912,18 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
conf->headers_hash_bucket_size = ngx_align(conf->headers_hash_bucket_size,
ngx_cacheline_size);
- if (conf->upstream.hide_headers == NULL
- && conf->upstream.pass_headers == NULL)
- {
- conf->upstream.hide_headers = prev->upstream.hide_headers;
- conf->upstream.pass_headers = prev->upstream.pass_headers;
- conf->upstream.hide_headers_hash = prev->upstream.hide_headers_hash;
-
- if (conf->upstream.hide_headers_hash.buckets) {
- goto peers;
- }
-
- } else {
- if (conf->upstream.hide_headers == NULL) {
- conf->upstream.hide_headers = prev->upstream.hide_headers;
- }
-
- if (conf->upstream.pass_headers == NULL) {
- conf->upstream.pass_headers = prev->upstream.pass_headers;
- }
- }
-
- if (ngx_array_init(&hide_headers, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
- != NGX_OK)
- {
- return NGX_CONF_ERROR;
- }
-
- for (header = ngx_http_proxy_hide_headers; header->len; header++) {
- hk = ngx_array_push(&hide_headers);
- if (hk == NULL) {
- return NGX_CONF_ERROR;
- }
-
- hk->key = *header;
- hk->key_hash = ngx_hash_key_lc(header->data, header->len);
- hk->value = (void *) 1;
- }
-
- if (conf->upstream.hide_headers) {
-
- header = conf->upstream.hide_headers->elts;
-
- for (i = 0; i < conf->upstream.hide_headers->nelts; i++) {
-
- hk = hide_headers.elts;
-
- for (j = 0; j < hide_headers.nelts; j++) {
- if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) {
- goto exist;
- }
- }
-
- hk = ngx_array_push(&hide_headers);
- if (hk == NULL) {
- return NGX_CONF_ERROR;
- }
-
- hk->key = header[i];
- hk->key_hash = ngx_hash_key_lc(header[i].data, header[i].len);
- hk->value = (void *) 1;
-
- exist:
-
- continue;
- }
- }
-
- if (conf->upstream.pass_headers) {
-
- hk = hide_headers.elts;
- header = conf->upstream.pass_headers->elts;
-
- for (i = 0; i < conf->upstream.pass_headers->nelts; i++) {
- for (j = 0; j < hide_headers.nelts; j++) {
-
- if (hk[j].key.data == NULL) {
- continue;
- }
-
- if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) {
- hk[j].key.data = NULL;
- break;
- }
- }
- }
- }
-
- hash.hash = &conf->upstream.hide_headers_hash;
- hash.key = ngx_hash_key_lc;
hash.max_size = conf->headers_hash_max_size;
hash.bucket_size = conf->headers_hash_bucket_size;
hash.name = "proxy_headers_hash";
- hash.pool = cf->pool;
- hash.temp_pool = NULL;
- if (ngx_hash_init(&hash, hide_headers.elts, hide_headers.nelts) != NGX_OK) {
+ if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
+ &prev->upstream,
+ ngx_http_proxy_hide_headers, &hash)
+ != NGX_OK)
+ {
return NGX_CONF_ERROR;
}
-peers:
-
if (conf->upstream.upstream == NULL) {
conf->upstream.upstream = prev->upstream.upstream;