comparison src/http/modules/ngx_http_fastcgi_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 7f3350b18e75
children 09dfe92b9414
comparison
equal deleted inserted replaced
1700:7f3350b18e75 1701:40d004d95d88
1641 * 1641 *
1642 * conf->upstream.bufs.num = 0; 1642 * conf->upstream.bufs.num = 0;
1643 * conf->upstream.next_upstream = 0; 1643 * conf->upstream.next_upstream = 0;
1644 * conf->upstream.temp_path = NULL; 1644 * conf->upstream.temp_path = NULL;
1645 * conf->upstream.hide_headers_hash = { NULL, 0 }; 1645 * conf->upstream.hide_headers_hash = { NULL, 0 };
1646 * conf->upstream.hide_headers = NULL;
1647 * conf->upstream.pass_headers = NULL;
1648 * conf->upstream.schema = { 0, NULL }; 1646 * conf->upstream.schema = { 0, NULL };
1649 * conf->upstream.uri = { 0, NULL }; 1647 * conf->upstream.uri = { 0, NULL };
1650 * conf->upstream.location = NULL; 1648 * conf->upstream.location = NULL;
1651 * conf->upstream.store_lengths = NULL; 1649 * conf->upstream.store_lengths = NULL;
1652 * conf->upstream.store_values = NULL; 1650 * conf->upstream.store_values = NULL;
1672 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE; 1670 conf->upstream.temp_file_write_size_conf = NGX_CONF_UNSET_SIZE;
1673 1671
1674 conf->upstream.pass_request_headers = NGX_CONF_UNSET; 1672 conf->upstream.pass_request_headers = NGX_CONF_UNSET;
1675 conf->upstream.pass_request_body = NGX_CONF_UNSET; 1673 conf->upstream.pass_request_body = NGX_CONF_UNSET;
1676 1674
1675 conf->upstream.hide_headers = NGX_CONF_UNSET_PTR;
1676 conf->upstream.pass_headers = NGX_CONF_UNSET_PTR;
1677
1677 conf->upstream.intercept_errors = NGX_CONF_UNSET; 1678 conf->upstream.intercept_errors = NGX_CONF_UNSET;
1678 1679
1679 /* "fastcgi_cyclic_temp_file" is disabled */ 1680 /* "fastcgi_cyclic_temp_file" is disabled */
1680 conf->upstream.cyclic_temp_file = 0; 1681 conf->upstream.cyclic_temp_file = 0;
1681 1682
1692 ngx_http_fastcgi_loc_conf_t *conf = child; 1693 ngx_http_fastcgi_loc_conf_t *conf = child;
1693 1694
1694 u_char *p; 1695 u_char *p;
1695 size_t size; 1696 size_t size;
1696 uintptr_t *code; 1697 uintptr_t *code;
1697 ngx_str_t *header; 1698 ngx_uint_t i;
1698 ngx_uint_t i, j;
1699 ngx_array_t hide_headers;
1700 ngx_keyval_t *src; 1699 ngx_keyval_t *src;
1701 ngx_hash_key_t *hk;
1702 ngx_hash_init_t hash; 1700 ngx_hash_init_t hash;
1703 ngx_http_script_compile_t sc; 1701 ngx_http_script_compile_t sc;
1704 ngx_http_script_copy_code_t *copy; 1702 ngx_http_script_copy_code_t *copy;
1705 1703
1706 if (conf->upstream.store != 0) { 1704 if (conf->upstream.store != 0) {
1858 ngx_conf_merge_ptr_value(conf->catch_stderr, prev->catch_stderr, NULL); 1856 ngx_conf_merge_ptr_value(conf->catch_stderr, prev->catch_stderr, NULL);
1859 1857
1860 1858
1861 ngx_conf_merge_str_value(conf->index, prev->index, ""); 1859 ngx_conf_merge_str_value(conf->index, prev->index, "");
1862 1860
1863 if (conf->upstream.hide_headers == NULL 1861 hash.max_size = 512;
1864 && conf->upstream.pass_headers == NULL) 1862 hash.bucket_size = ngx_align(64, ngx_cacheline_size);
1865 { 1863 hash.name = "fastcgi_hide_headers_hash";
1866 conf->upstream.hide_headers = prev->upstream.hide_headers; 1864
1867 conf->upstream.pass_headers = prev->upstream.pass_headers; 1865 if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
1868 conf->upstream.hide_headers_hash = prev->upstream.hide_headers_hash; 1866 &prev->upstream,
1869 1867 ngx_http_fastcgi_hide_headers,
1870 if (conf->upstream.hide_headers_hash.buckets) { 1868 &hash)
1871 goto peers;
1872 }
1873
1874 } else {
1875 if (conf->upstream.hide_headers == NULL) {
1876 conf->upstream.hide_headers = prev->upstream.hide_headers;
1877 }
1878
1879 if (conf->upstream.pass_headers == NULL) {
1880 conf->upstream.pass_headers = prev->upstream.pass_headers;
1881 }
1882 }
1883
1884 if (ngx_array_init(&hide_headers, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
1885 != NGX_OK) 1869 != NGX_OK)
1886 { 1870 {
1887 return NGX_CONF_ERROR; 1871 return NGX_CONF_ERROR;
1888 } 1872 }
1889
1890 for (header = ngx_http_fastcgi_hide_headers; header->len; header++) {
1891 hk = ngx_array_push(&hide_headers);
1892 if (hk == NULL) {
1893 return NGX_CONF_ERROR;
1894 }
1895
1896 hk->key = *header;
1897 hk->key_hash = ngx_hash_key_lc(header->data, header->len);
1898 hk->value = (void *) 1;
1899 }
1900
1901 if (conf->upstream.hide_headers) {
1902
1903 header = conf->upstream.hide_headers->elts;
1904
1905 for (i = 0; i < conf->upstream.hide_headers->nelts; i++) {
1906
1907 hk = hide_headers.elts;
1908
1909 for (j = 0; j < hide_headers.nelts; j++) {
1910 if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) {
1911 goto exist;
1912 }
1913 }
1914
1915 hk = ngx_array_push(&hide_headers);
1916 if (hk == NULL) {
1917 return NGX_CONF_ERROR;
1918 }
1919
1920 hk->key = header[i];
1921 hk->key_hash = ngx_hash_key_lc(header[i].data, header[i].len);
1922 hk->value = (void *) 1;
1923
1924 exist:
1925
1926 continue;
1927 }
1928 }
1929
1930 if (conf->upstream.pass_headers) {
1931
1932 hk = hide_headers.elts;
1933 header = conf->upstream.pass_headers->elts;
1934
1935 for (i = 0; i < conf->upstream.pass_headers->nelts; i++) {
1936
1937 for (j = 0; j < hide_headers.nelts; j++) {
1938
1939 if (hk[j].key.data == NULL) {
1940 continue;
1941 }
1942
1943 if (ngx_strcasecmp(header[i].data, hk[j].key.data) == 0) {
1944 hk[j].key.data = NULL;
1945 break;
1946 }
1947 }
1948 }
1949 }
1950
1951 hash.hash = &conf->upstream.hide_headers_hash;
1952 hash.key = ngx_hash_key_lc;
1953 hash.max_size = 512;
1954 hash.bucket_size = ngx_align(64, ngx_cacheline_size);
1955 hash.name = "fastcgi_hide_headers_hash";
1956 hash.pool = cf->pool;
1957 hash.temp_pool = NULL;
1958
1959 if (ngx_hash_init(&hash, hide_headers.elts, hide_headers.nelts) != NGX_OK) {
1960 return NGX_CONF_ERROR;
1961 }
1962
1963 peers:
1964 1873
1965 if (conf->upstream.upstream == NULL) { 1874 if (conf->upstream.upstream == NULL) {
1966 conf->upstream.upstream = prev->upstream.upstream; 1875 conf->upstream.upstream = prev->upstream.upstream;
1967 conf->upstream.schema = prev->upstream.schema; 1876 conf->upstream.schema = prev->upstream.schema;
1968 } 1877 }