Mercurial > hg > nginx-mail
comparison src/http/modules/ngx_http_proxy_module.c @ 356:b743d290eb3b NGINX_0_6_22
nginx 0.6.22
*) Change: now all ngx_http_perl_module methods return values copied to
perl's allocated memory.
*) Bugfix: if nginx was built with ngx_http_perl_module, the perl
before 5.8.6 was used, and perl supported threads, then during
reconfiguration the master process aborted; bug appeared in
0.5.9.
Thanks to Boris Zhmurov.
*) Bugfix: the ngx_http_perl_module methods may get invalid values of
the regex captures.
*) Bugfix: a segmentation fault occurred in worker process, if the
$r->has_request_body() method was called for a request whose small
request body was already received.
*) Bugfix: large_client_header_buffers did not freed before going to
keep-alive state.
Thanks to Olexander Shtepa.
*) Bugfix: the last address was missed in the $upstream_addr variable;
bug appeared in 0.6.18.
*) Bugfix: the "fastcgi_catch_stderr" directive did return error code;
now it returns 502 code, that can be rerouted to a next server using
the "fastcgi_next_upstream invalid_header" directive.
*) Bugfix: a segmentation fault occurred in master process if the
"fastcgi_catch_stderr" directive was used; bug appeared in
0.6.10.
Thanks to Manlio Perillo.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 19 Dec 2007 00:00:00 +0300 |
parents | 583decdb82a4 |
children | 9121a0a91f47 |
comparison
equal
deleted
inserted
replaced
355:3ac45897a61c | 356:b743d290eb3b |
---|---|
957 ngx_http_proxy_ctx_t *ctx; | 957 ngx_http_proxy_ctx_t *ctx; |
958 | 958 |
959 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | 959 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); |
960 | 960 |
961 if (ctx == NULL) { | 961 if (ctx == NULL) { |
962 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 962 return NGX_ERROR; |
963 } | 963 } |
964 | 964 |
965 rc = ngx_http_proxy_parse_status_line(r, ctx); | 965 rc = ngx_http_proxy_parse_status_line(r, ctx); |
966 | 966 |
967 if (rc == NGX_AGAIN) { | 967 if (rc == NGX_AGAIN) { |
992 | 992 |
993 u->headers_in.status_line.len = ctx->status_end - ctx->status_start; | 993 u->headers_in.status_line.len = ctx->status_end - ctx->status_start; |
994 u->headers_in.status_line.data = ngx_palloc(r->pool, | 994 u->headers_in.status_line.data = ngx_palloc(r->pool, |
995 u->headers_in.status_line.len); | 995 u->headers_in.status_line.len); |
996 if (u->headers_in.status_line.data == NULL) { | 996 if (u->headers_in.status_line.data == NULL) { |
997 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 997 return NGX_ERROR; |
998 } | 998 } |
999 | 999 |
1000 ngx_memcpy(u->headers_in.status_line.data, ctx->status_start, | 1000 ngx_memcpy(u->headers_in.status_line.data, ctx->status_start, |
1001 u->headers_in.status_line.len); | 1001 u->headers_in.status_line.len); |
1002 | 1002 |
1237 | 1237 |
1238 /* a header line has been parsed successfully */ | 1238 /* a header line has been parsed successfully */ |
1239 | 1239 |
1240 h = ngx_list_push(&r->upstream->headers_in.headers); | 1240 h = ngx_list_push(&r->upstream->headers_in.headers); |
1241 if (h == NULL) { | 1241 if (h == NULL) { |
1242 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1242 return NGX_ERROR; |
1243 } | 1243 } |
1244 | 1244 |
1245 h->hash = r->header_hash; | 1245 h->hash = r->header_hash; |
1246 | 1246 |
1247 h->key.len = r->header_name_end - r->header_name_start; | 1247 h->key.len = r->header_name_end - r->header_name_start; |
1248 h->value.len = r->header_end - r->header_start; | 1248 h->value.len = r->header_end - r->header_start; |
1249 | 1249 |
1250 h->key.data = ngx_palloc(r->pool, | 1250 h->key.data = ngx_palloc(r->pool, |
1251 h->key.len + 1 + h->value.len + 1 + h->key.len); | 1251 h->key.len + 1 + h->value.len + 1 + h->key.len); |
1252 if (h->key.data == NULL) { | 1252 if (h->key.data == NULL) { |
1253 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1253 return NGX_ERROR; |
1254 } | 1254 } |
1255 | 1255 |
1256 h->value.data = h->key.data + h->key.len + 1; | 1256 h->value.data = h->key.data + h->key.len + 1; |
1257 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; | 1257 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; |
1258 | 1258 |
1270 | 1270 |
1271 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, | 1271 hh = ngx_hash_find(&umcf->headers_in_hash, h->hash, |
1272 h->lowcase_key, h->key.len); | 1272 h->lowcase_key, h->key.len); |
1273 | 1273 |
1274 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { | 1274 if (hh && hh->handler(r, h, hh->offset) != NGX_OK) { |
1275 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1275 return NGX_ERROR; |
1276 } | 1276 } |
1277 | 1277 |
1278 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1278 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1279 "http proxy header: \"%V: %V\"", | 1279 "http proxy header: \"%V: %V\"", |
1280 &h->key, &h->value); | 1280 &h->key, &h->value); |
1295 */ | 1295 */ |
1296 | 1296 |
1297 if (r->upstream->headers_in.server == NULL) { | 1297 if (r->upstream->headers_in.server == NULL) { |
1298 h = ngx_list_push(&r->upstream->headers_in.headers); | 1298 h = ngx_list_push(&r->upstream->headers_in.headers); |
1299 if (h == NULL) { | 1299 if (h == NULL) { |
1300 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1300 return NGX_ERROR; |
1301 } | 1301 } |
1302 | 1302 |
1303 h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash( | 1303 h->hash = ngx_hash(ngx_hash(ngx_hash(ngx_hash( |
1304 ngx_hash('s', 'e'), 'r'), 'v'), 'e'), 'r'); | 1304 ngx_hash('s', 'e'), 'r'), 'v'), 'e'), 'r'); |
1305 | 1305 |
1311 } | 1311 } |
1312 | 1312 |
1313 if (r->upstream->headers_in.date == NULL) { | 1313 if (r->upstream->headers_in.date == NULL) { |
1314 h = ngx_list_push(&r->upstream->headers_in.headers); | 1314 h = ngx_list_push(&r->upstream->headers_in.headers); |
1315 if (h == NULL) { | 1315 if (h == NULL) { |
1316 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 1316 return NGX_ERROR; |
1317 } | 1317 } |
1318 | 1318 |
1319 h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e'); | 1319 h->hash = ngx_hash(ngx_hash(ngx_hash('d', 'a'), 't'), 'e'); |
1320 | 1320 |
1321 h->key.len = sizeof("Date") - 1; | 1321 h->key.len = sizeof("Date") - 1; |
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; |