comparison src/http/ngx_http_upstream.c @ 1701:40d004d95d88

*) 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()
author Igor Sysoev <igor@sysoev.ru>
date Sun, 09 Dec 2007 18:03:20 +0000
parents 976db8c6fb64
children d22095839d86
comparison
equal deleted inserted replaced
1700:7f3350b18e75 1701:40d004d95d88
3406 3406
3407 return uscf; 3407 return uscf;
3408 } 3408 }
3409 3409
3410 3410
3411 ngx_int_t
3412 ngx_http_upstream_hide_headers_hash(ngx_conf_t *cf,
3413 ngx_http_upstream_conf_t *conf, ngx_http_upstream_conf_t *prev,
3414 ngx_str_t *default_hide_headers, ngx_hash_init_t *hash)
3415 {
3416 ngx_str_t *h;
3417 ngx_uint_t i, j;
3418 ngx_array_t hide_headers;
3419 ngx_hash_key_t *hk;
3420
3421 if (conf->hide_headers == NGX_CONF_UNSET_PTR
3422 && conf->pass_headers == NGX_CONF_UNSET_PTR)
3423 {
3424 conf->hide_headers_hash = prev->hide_headers_hash;
3425
3426 if (conf->hide_headers_hash.buckets) {
3427 return NGX_OK;
3428 }
3429
3430 conf->hide_headers = prev->hide_headers;
3431 conf->pass_headers = prev->pass_headers;
3432
3433 } else {
3434 if (conf->hide_headers == NGX_CONF_UNSET_PTR) {
3435 conf->hide_headers = prev->hide_headers;
3436 }
3437
3438 if (conf->pass_headers == NGX_CONF_UNSET_PTR) {
3439 conf->pass_headers = prev->pass_headers;
3440 }
3441 }
3442
3443 if (ngx_array_init(&hide_headers, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
3444 != NGX_OK)
3445 {
3446 return NGX_ERROR;
3447 }
3448
3449 for (h = default_hide_headers; h->len; h++) {
3450 hk = ngx_array_push(&hide_headers);
3451 if (hk == NULL) {
3452 return NGX_ERROR;
3453 }
3454
3455 hk->key = *h;
3456 hk->key_hash = ngx_hash_key_lc(h->data, h->len);
3457 hk->value = (void *) 1;
3458 }
3459
3460 if (conf->hide_headers != NGX_CONF_UNSET_PTR) {
3461
3462 h = conf->hide_headers->elts;
3463
3464 for (i = 0; i < conf->hide_headers->nelts; i++) {
3465
3466 hk = hide_headers.elts;
3467
3468 for (j = 0; j < hide_headers.nelts; j++) {
3469 if (ngx_strcasecmp(h[i].data, hk[j].key.data) == 0) {
3470 goto exist;
3471 }
3472 }
3473
3474 hk = ngx_array_push(&hide_headers);
3475 if (hk == NULL) {
3476 return NGX_ERROR;
3477 }
3478
3479 hk->key = h[i];
3480 hk->key_hash = ngx_hash_key_lc(h[i].data, h[i].len);
3481 hk->value = (void *) 1;
3482
3483 exist:
3484
3485 continue;
3486 }
3487 }
3488
3489 if (conf->pass_headers != NGX_CONF_UNSET_PTR) {
3490
3491 h = conf->pass_headers->elts;
3492 hk = hide_headers.elts;
3493
3494 for (i = 0; i < conf->pass_headers->nelts; i++) {
3495 for (j = 0; j < hide_headers.nelts; j++) {
3496
3497 if (hk[j].key.data == NULL) {
3498 continue;
3499 }
3500
3501 if (ngx_strcasecmp(h[i].data, hk[j].key.data) == 0) {
3502 hk[j].key.data = NULL;
3503 break;
3504 }
3505 }
3506 }
3507 }
3508
3509 hash->hash = &conf->hide_headers_hash;
3510 hash->key = ngx_hash_key_lc;
3511 hash->pool = cf->pool;
3512 hash->temp_pool = NULL;
3513
3514 return ngx_hash_init(hash, hide_headers.elts, hide_headers.nelts);
3515 }
3516
3517
3411 static void * 3518 static void *
3412 ngx_http_upstream_create_main_conf(ngx_conf_t *cf) 3519 ngx_http_upstream_create_main_conf(ngx_conf_t *cf)
3413 { 3520 {
3414 ngx_http_upstream_main_conf_t *umcf; 3521 ngx_http_upstream_main_conf_t *umcf;
3415 3522