Mercurial > hg > nginx-vendor-0-8
comparison src/http/ngx_http_upstream.c @ 78:9db7e0b5b27f NGINX_0_1_39
nginx 0.1.39
*) The changes in the ngx_http_charset_module: the "default_charset"
directive was canceled; the "charset" directive sets the response
charset; the "source_charset" directive sets the source charset only.
*) Bugfix: the backend "WWW-Authenticate" header line did not
transferred while the 401 response code redirecting.
*) Bugfix: the ngx_http_proxy_module and ngx_http_fastcgi_module may
close a connection before anything was transferred to a client; bug
appeared in 0.1.38.
*) Workaround: the Linux glibc crypt_r() initialization bug.
*) Bugfix: the ngx_http_ssi_module did not support the relative URI in
the "include virtual" command.
*) Bugfix: if the backend response had the "Location" header line and
nginx should not rewrite this line, then the 500 code response body
was transferred; bug appeared in 0.1.29.
*) Bugfix: some directives of the ngx_http_proxy_module and
ngx_http_fastcgi_module were not inherited from the server to the
location level; bug appeared in 0.1.29.
*) Bugfix: the ngx_http_ssl_module did not support the certificate
chain.
*) Bugfix: the ngx_http_autoindex_module did not show correctly the
long file names; bug appeared in 0.1.38.
*) Bugfixes in IMAP/POP3 proxy in interaction with a backend at the
login state.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 14 Jul 2005 00:00:00 +0400 |
parents | da9a3b14312d |
children | 6ae11d59d10e |
comparison
equal
deleted
inserted
replaced
77:e6b3de2dc637 | 78:9db7e0b5b27f |
---|---|
101 ngx_http_upstream_process_header_line, | 101 ngx_http_upstream_process_header_line, |
102 offsetof(ngx_http_upstream_headers_in_t, server), | 102 offsetof(ngx_http_upstream_headers_in_t, server), |
103 ngx_http_upstream_conditional_copy_header_line, | 103 ngx_http_upstream_conditional_copy_header_line, |
104 offsetof(ngx_http_upstream_conf_t, pass_server), 0 }, | 104 offsetof(ngx_http_upstream_conf_t, pass_server), 0 }, |
105 | 105 |
106 { ngx_string("WWW-Authenticate"), | |
107 ngx_http_upstream_process_header_line, | |
108 offsetof(ngx_http_upstream_headers_in_t, www_authenticate), | |
109 ngx_http_upstream_copy_header_line, 0, 0 }, | |
110 | |
106 { ngx_string("Location"), | 111 { ngx_string("Location"), |
107 ngx_http_upstream_ignore_header_line, 0, | 112 ngx_http_upstream_ignore_header_line, 0, |
108 ngx_http_upstream_rewrite_location, 0, 0 }, | 113 ngx_http_upstream_rewrite_location, 0, 0 }, |
109 | 114 |
110 { ngx_string("Refresh"), | 115 { ngx_string("Refresh"), |
111 ngx_http_upstream_ignore_header_line, 0, | 116 ngx_http_upstream_ignore_header_line, 0, |
112 ngx_http_upstream_rewrite_refresh, 0, 0 }, | 117 ngx_http_upstream_rewrite_refresh, 0, 0 }, |
113 | 118 |
114 { ngx_string("Set-Cookie"), | 119 { ngx_string("Set-Cookie"), |
115 ngx_http_upstream_ignore_header_line, 0, | 120 ngx_http_upstream_ignore_header_line, 0, |
116 ngx_http_upstream_copy_header_line, 0, 1 }, | 121 ngx_http_upstream_copy_header_line, 0, 0 }, |
117 | 122 |
118 { ngx_string("Cache-Control"), | 123 { ngx_string("Cache-Control"), |
119 ngx_http_upstream_process_multi_header_lines, | 124 ngx_http_upstream_process_multi_header_lines, |
120 offsetof(ngx_http_upstream_headers_in_t, cache_control), | 125 offsetof(ngx_http_upstream_headers_in_t, cache_control), |
121 ngx_http_upstream_copy_multi_header_lines, | 126 ngx_http_upstream_copy_multi_header_lines, |
384 | 389 |
385 if (n > 0) { | 390 if (n > 0) { |
386 return; | 391 return; |
387 } | 392 } |
388 | 393 |
389 ev->eof = 1; | |
390 c->closed = 1; | |
391 | |
392 if (n == -1) { | 394 if (n == -1) { |
393 if (err == NGX_EAGAIN) { | 395 if (err == NGX_EAGAIN) { |
394 return; | 396 return; |
395 } | 397 } |
396 | 398 |
397 ev->error = 1; | 399 ev->error = 1; |
398 | 400 |
399 } else { /* n == 0 */ | 401 } else { /* n == 0 */ |
400 err = 0; | 402 err = 0; |
401 } | 403 } |
404 | |
405 ev->eof = 1; | |
406 c->closed = 1; | |
402 | 407 |
403 if (!u->cachable && u->peer.connection) { | 408 if (!u->cachable && u->peer.connection) { |
404 ngx_log_error(NGX_LOG_INFO, ev->log, err, | 409 ngx_log_error(NGX_LOG_INFO, ev->log, err, |
405 "client closed prematurely connection, " | 410 "client closed prematurely connection, " |
406 "so upstream connection is closed too"); | 411 "so upstream connection is closed too"); |
849 return; | 854 return; |
850 } | 855 } |
851 | 856 |
852 /* rc == NGX_OK */ | 857 /* rc == NGX_OK */ |
853 | 858 |
854 if (r->headers_out.status == NGX_HTTP_INTERNAL_SERVER_ERROR) { | 859 if (u->headers_in.status_n == NGX_HTTP_INTERNAL_SERVER_ERROR) { |
855 | 860 |
856 if (u->peer.tries > 1 | 861 if (u->peer.tries > 1 |
857 && (u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_500)) | 862 && (u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_500)) |
858 { | 863 { |
859 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_500); | 864 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_500); |
865 if (u->peer.tries == 0 | 870 if (u->peer.tries == 0 |
866 && u->stale | 871 && u->stale |
867 && (u->conf->use_stale & NGX_HTTP_UPSTREAM_FT_HTTP_500)) | 872 && (u->conf->use_stale & NGX_HTTP_UPSTREAM_FT_HTTP_500)) |
868 { | 873 { |
869 ngx_http_upstream_finalize_request(r, u, | 874 ngx_http_upstream_finalize_request(r, u, |
870 ngx_http_send_cached_response(r)); | 875 ngx_http_send_cached_response(r)); |
871 return; | 876 return; |
872 } | 877 } |
873 | 878 |
874 #endif | 879 #endif |
875 } | 880 } |
876 | 881 |
877 if (r->headers_out.status == NGX_HTTP_NOT_FOUND | 882 if (u->headers_in.status_n == NGX_HTTP_NOT_FOUND |
878 && u->peer.tries > 1 | 883 && u->peer.tries > 1 |
879 && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_404) | 884 && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_404) |
880 { | 885 { |
881 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_404); | 886 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_404); |
882 return; | 887 return; |
883 } | 888 } |
884 | 889 |
885 | 890 |
886 if (r->headers_out.status >= NGX_HTTP_BAD_REQUEST | 891 if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST |
887 && u->conf->redirect_errors | 892 && u->conf->redirect_errors |
888 && r->err_ctx == NULL) | 893 && r->err_ctx == NULL) |
889 { | 894 { |
890 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 895 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
891 | 896 |
892 if (clcf->error_pages) { | 897 if (clcf->error_pages) { |
893 | 898 |
894 err_page = clcf->error_pages->elts; | 899 err_page = clcf->error_pages->elts; |
895 for (i = 0; i < clcf->error_pages->nelts; i++) { | 900 for (i = 0; i < clcf->error_pages->nelts; i++) { |
896 if (err_page[i].status == (ngx_int_t) r->headers_out.status) { | 901 if (err_page[i].status == (ngx_int_t) u->headers_in.status_n) { |
902 | |
903 if (u->headers_in.status_n == NGX_HTTP_UNAUTHORIZED) { | |
904 | |
905 r->headers_out.www_authenticate = | |
906 ngx_list_push(&r->headers_out.headers); | |
907 | |
908 if (r->headers_out.www_authenticate == NULL) { | |
909 ngx_http_upstream_finalize_request(r, u, | |
910 NGX_HTTP_INTERNAL_SERVER_ERROR); | |
911 return; | |
912 } | |
913 | |
914 *r->headers_out.www_authenticate = | |
915 *u->headers_in.www_authenticate; | |
916 } | |
917 | |
897 ngx_http_upstream_finalize_request(r, u, | 918 ngx_http_upstream_finalize_request(r, u, |
898 r->headers_out.status); | 919 u->headers_in.status_n); |
899 return; | 920 return; |
900 } | 921 } |
901 } | 922 } |
902 } | 923 } |
903 } | 924 } |
936 } | 957 } |
937 | 958 |
938 } | 959 } |
939 } | 960 } |
940 | 961 |
941 r->headers_out.status_line.len = 0; | |
942 | |
943 ngx_http_internal_redirect(r, | 962 ngx_http_internal_redirect(r, |
944 &r->upstream->headers_in.x_accel_redirect->value, | 963 &r->upstream->headers_in.x_accel_redirect->value, |
945 NULL); | 964 NULL); |
946 return; | 965 return; |
947 } | 966 } |
998 ngx_http_upstream_finalize_request(r, u, | 1017 ngx_http_upstream_finalize_request(r, u, |
999 NGX_HTTP_INTERNAL_SERVER_ERROR); | 1018 NGX_HTTP_INTERNAL_SERVER_ERROR); |
1000 return; | 1019 return; |
1001 } | 1020 } |
1002 } | 1021 } |
1022 | |
1023 r->headers_out.status = u->headers_in.status_n; | |
1024 r->headers_out.status_line = u->headers_in.status_line; | |
1003 | 1025 |
1004 rc = ngx_http_send_header(r); | 1026 rc = ngx_http_send_header(r); |
1005 | 1027 |
1006 if (rc == NGX_ERROR || rc > NGX_OK) { | 1028 if (rc == NGX_ERROR || rc > NGX_OK) { |
1007 ngx_http_upstream_finalize_request(r, u, rc); | 1029 ngx_http_upstream_finalize_request(r, u, rc); |
1620 *ho = *h; | 1642 *ho = *h; |
1621 | 1643 |
1622 if (r->upstream->rewrite_redirect) { | 1644 if (r->upstream->rewrite_redirect) { |
1623 rc = r->upstream->rewrite_redirect(r, ho, 0); | 1645 rc = r->upstream->rewrite_redirect(r, ho, 0); |
1624 | 1646 |
1647 if (rc == NGX_DECLINED) { | |
1648 return NGX_OK; | |
1649 } | |
1650 | |
1625 if (rc == NGX_OK) { | 1651 if (rc == NGX_OK) { |
1626 r->headers_out.location = ho; | 1652 r->headers_out.location = ho; |
1627 | 1653 |
1628 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1654 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1629 "rewritten location: \"%V\"", &ho->value); | 1655 "rewritten location: \"%V\"", &ho->value); |
1662 | 1688 |
1663 if (p) { | 1689 if (p) { |
1664 rc = r->upstream->rewrite_redirect(r, ho, p + 4 - ho->value.data); | 1690 rc = r->upstream->rewrite_redirect(r, ho, p + 4 - ho->value.data); |
1665 | 1691 |
1666 } else { | 1692 } else { |
1693 return NGX_OK; | |
1694 } | |
1695 | |
1696 if (rc == NGX_DECLINED) { | |
1667 return NGX_OK; | 1697 return NGX_OK; |
1668 } | 1698 } |
1669 | 1699 |
1670 #if (NGX_DEBUG) | 1700 #if (NGX_DEBUG) |
1671 if (rc == NGX_OK) { | 1701 if (rc == NGX_OK) { |