Mercurial > hg > nginx
comparison src/http/modules/ngx_http_proxy_module.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 | 68d21fd1dc64 |
comparison
equal
deleted
inserted
replaced
1700:7f3350b18e75 | 1701:40d004d95d88 |
---|---|
1632 * | 1632 * |
1633 * conf->upstream.bufs.num = 0; | 1633 * conf->upstream.bufs.num = 0; |
1634 * conf->upstream.next_upstream = 0; | 1634 * conf->upstream.next_upstream = 0; |
1635 * conf->upstream.temp_path = NULL; | 1635 * conf->upstream.temp_path = NULL; |
1636 * conf->upstream.hide_headers_hash = { NULL, 0 }; | 1636 * conf->upstream.hide_headers_hash = { NULL, 0 }; |
1637 * conf->upstream.hide_headers = NULL; | |
1638 * conf->upstream.pass_headers = NULL; | |
1639 * conf->upstream.schema = { 0, NULL }; | 1637 * conf->upstream.schema = { 0, NULL }; |
1640 * conf->upstream.uri = { 0, NULL }; | 1638 * conf->upstream.uri = { 0, NULL }; |
1641 * conf->upstream.location = NULL; | 1639 * conf->upstream.location = NULL; |
1642 * conf->upstream.store_lengths = NULL; | 1640 * conf->upstream.store_lengths = NULL; |
1643 * conf->upstream.store_values = NULL; | 1641 * conf->upstream.store_values = NULL; |
1670 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; | 1668 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; |
1671 | 1669 |
1672 conf->upstream.pass_request_headers = NGX_CONF_UNSET; | 1670 conf->upstream.pass_request_headers = NGX_CONF_UNSET; |
1673 conf->upstream.pass_request_body = NGX_CONF_UNSET; | 1671 conf->upstream.pass_request_body = NGX_CONF_UNSET; |
1674 | 1672 |
1673 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR; | |
1674 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR; | |
1675 | |
1675 conf->upstream.intercept_errors = NGX_CONF_UNSET; | 1676 conf->upstream.intercept_errors = NGX_CONF_UNSET; |
1676 | 1677 |
1677 /* "proxy_cyclic_temp_file" is disabled */ | 1678 /* "proxy_cyclic_temp_file" is disabled */ |
1678 conf->upstream.cyclic_temp_file = 0; | 1679 conf->upstream.cyclic_temp_file = 0; |
1679 | 1680 |
1694 ngx_http_proxy_loc_conf_t *conf = child; | 1695 ngx_http_proxy_loc_conf_t *conf = child; |
1695 | 1696 |
1696 u_char *p; | 1697 u_char *p; |
1697 size_t size; | 1698 size_t size; |
1698 uintptr_t *code; | 1699 uintptr_t *code; |
1699 ngx_str_t *header; | 1700 ngx_uint_t i; |
1700 ngx_uint_t i, j; | |
1701 ngx_array_t hide_headers; | |
1702 ngx_keyval_t *src, *s, *h; | 1701 ngx_keyval_t *src, *s, *h; |
1703 ngx_hash_key_t *hk; | 1702 ngx_hash_key_t *hk; |
1704 ngx_hash_init_t hash; | 1703 ngx_hash_init_t hash; |
1705 ngx_http_proxy_redirect_t *pr; | 1704 ngx_http_proxy_redirect_t *pr; |
1706 ngx_http_script_compile_t sc; | 1705 ngx_http_script_compile_t sc; |
1911 prev->headers_hash_bucket_size, 64); | 1910 prev->headers_hash_bucket_size, 64); |
1912 | 1911 |
1913 conf->headers_hash_bucket_size = ngx_align(conf->headers_hash_bucket_size, | 1912 conf->headers_hash_bucket_size = ngx_align(conf->headers_hash_bucket_size, |
1914 ngx_cacheline_size); | 1913 ngx_cacheline_size); |
1915 | 1914 |
1916 if (conf->upstream.hide_headers == NULL | 1915 hash.max_size = conf->headers_hash_max_size; |
1917 && conf->upstream.pass_headers == NULL) | 1916 hash.bucket_size = conf->headers_hash_bucket_size; |
1918 { | 1917 hash.name = "proxy_headers_hash"; |
1919 conf->upstream.hide_headers = prev->upstream.hide_headers; | 1918 |
1920 conf->upstream.pass_headers = prev->upstream.pass_headers; | 1919 if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream, |
1921 conf->upstream.hide_headers_hash = prev->upstream.hide_headers_hash; | 1920 &prev->upstream, |
1922 | 1921 ngx_http_proxy_hide_headers, &hash) |
1923 if (conf->upstream.hide_headers_hash.buckets) { | |
1924 goto peers; | |
1925 } | |
1926 | |
1927 } else { | |
1928 if (conf->upstream.hide_headers == NULL) { | |
1929 conf->upstream.hide_headers = prev->upstream.hide_headers; | |
1930 } | |
1931 | |
1932 if (conf->upstream.pass_headers == NULL) { | |
1933 conf->upstream.pass_headers = prev->upstream.pass_headers; | |
1934 } | |
1935 } | |
1936 | |
1937 if (ngx_array_init(&hide_headers, cf->temp_pool, 4, sizeof(ngx_hash_key_t)) | |
1938 != NGX_OK) | 1922 != NGX_OK) |
1939 { | 1923 { |
1940 return NGX_CONF_ERROR; | 1924 return NGX_CONF_ERROR; |
1941 } | 1925 } |
1942 | |
1943 for (header = ngx_http_proxy_hide_headers; header->len; header++) { | |
1944 hk = ngx_array_push(&hide_headers); | |
1945 if (hk == NULL) { | |
1946 return NGX_CONF_ERROR; | |
1947 } | |
1948 | |
1949 hk->key = *header; | |
1950 hk->key_hash = ngx_hash_key_lc(header->data, header->len); | |
1951 hk->value = (void *) 1; | |
1952 } | |
1953 | |
1954 if (conf->upstream.hide_headers) { | |
1955 | |
1956 header = conf->upstream.hide_headers->elts; | |
1957 | |
1958 for (i = 0; i < conf->upstream.hide_headers->nelts; i++) { | |
1959 | |
1960 hk = hide_headers.elts; | |
1961 | |
1962 for (j = 0; j < hide_headers.nelts; j++) { | |
1963 if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) { | |
1964 goto exist; | |
1965 } | |
1966 } | |
1967 | |
1968 hk = ngx_array_push(&hide_headers); | |
1969 if (hk == NULL) { | |
1970 return NGX_CONF_ERROR; | |
1971 } | |
1972 | |
1973 hk->key = header[i]; | |
1974 hk->key_hash = ngx_hash_key_lc(header[i].data, header[i].len); | |
1975 hk->value = (void *) 1; | |
1976 | |
1977 exist: | |
1978 | |
1979 continue; | |
1980 } | |
1981 } | |
1982 | |
1983 if (conf->upstream.pass_headers) { | |
1984 | |
1985 hk = hide_headers.elts; | |
1986 header = conf->upstream.pass_headers->elts; | |
1987 | |
1988 for (i = 0; i < conf->upstream.pass_headers->nelts; i++) { | |
1989 for (j = 0; j < hide_headers.nelts; j++) { | |
1990 | |
1991 if (hk[j].key.data == NULL) { | |
1992 continue; | |
1993 } | |
1994 | |
1995 if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) { | |
1996 hk[j].key.data = NULL; | |
1997 break; | |
1998 } | |
1999 } | |
2000 } | |
2001 } | |
2002 | |
2003 hash.hash = &conf->upstream.hide_headers_hash; | |
2004 hash.key = ngx_hash_key_lc; | |
2005 hash.max_size = conf->headers_hash_max_size; | |
2006 hash.bucket_size = conf->headers_hash_bucket_size; | |
2007 hash.name = "proxy_headers_hash"; | |
2008 hash.pool = cf->pool; | |
2009 hash.temp_pool = NULL; | |
2010 | |
2011 if (ngx_hash_init(&hash, hide_headers.elts, hide_headers.nelts) != NGX_OK) { | |
2012 return NGX_CONF_ERROR; | |
2013 } | |
2014 | |
2015 peers: | |
2016 | 1926 |
2017 if (conf->upstream.upstream == NULL) { | 1927 if (conf->upstream.upstream == NULL) { |
2018 conf->upstream.upstream = prev->upstream.upstream; | 1928 conf->upstream.upstream = prev->upstream.upstream; |
2019 | 1929 |
2020 conf->vars = prev->vars; | 1930 conf->vars = prev->vars; |