Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 657:400711951595 release-0.3.50
nginx-0.3.50-RELEASE import
*) Change: the "proxy_redirect_errors" and "fastcgi_redirect_errors"
directives was renamed to the "proxy_intercept_errors" and
"fastcgi_intercept_errors" directives.
*) Feature: the ngx_http_charset_module supports the recoding from the
single byte encodings to the UTF-8 encoding and back.
*) Feature: the "X-Accel-Charset" response header line is supported in
proxy and FastCGI mode.
*) Bugfix: the "\" escape symbol in the "\"" and "\'" pairs in the SSI
command was removed only if the command also has the "$" symbol.
*) Bugfix: the "<!--" string might be added on some conditions in the
SSI after inclusion.
*) Bugfix: if the "Content-Length: 0" header line was in response, then
in nonbuffered proxying mode the client connection was not closed.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 28 Jun 2006 16:00:26 +0000 |
parents | 7cbef16c71a1 |
children | 649c9063d0fd |
comparison
equal
deleted
inserted
replaced
656:97f36f8e65dd | 657:400711951595 |
---|---|
47 ngx_table_elt_t *h, ngx_uint_t offset); | 47 ngx_table_elt_t *h, ngx_uint_t offset); |
48 static ngx_int_t ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, | 48 static ngx_int_t ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, |
49 ngx_table_elt_t *h, ngx_uint_t offset); | 49 ngx_table_elt_t *h, ngx_uint_t offset); |
50 static ngx_int_t ngx_http_upstream_process_buffering(ngx_http_request_t *r, | 50 static ngx_int_t ngx_http_upstream_process_buffering(ngx_http_request_t *r, |
51 ngx_table_elt_t *h, ngx_uint_t offset); | 51 ngx_table_elt_t *h, ngx_uint_t offset); |
52 static ngx_int_t ngx_http_upstream_process_charset(ngx_http_request_t *r, | |
53 ngx_table_elt_t *h, ngx_uint_t offset); | |
52 static ngx_int_t ngx_http_upstream_copy_header_line(ngx_http_request_t *r, | 54 static ngx_int_t ngx_http_upstream_copy_header_line(ngx_http_request_t *r, |
53 ngx_table_elt_t *h, ngx_uint_t offset); | 55 ngx_table_elt_t *h, ngx_uint_t offset); |
54 static ngx_int_t | 56 static ngx_int_t |
55 ngx_http_upstream_copy_multi_header_lines(ngx_http_request_t *r, | 57 ngx_http_upstream_copy_multi_header_lines(ngx_http_request_t *r, |
56 ngx_table_elt_t *h, ngx_uint_t offset); | 58 ngx_table_elt_t *h, ngx_uint_t offset); |
197 | 199 |
198 { ngx_string("X-Accel-Buffering"), | 200 { ngx_string("X-Accel-Buffering"), |
199 ngx_http_upstream_process_buffering, 0, | 201 ngx_http_upstream_process_buffering, 0, |
200 ngx_http_upstream_ignore_header_line, 0, 0 }, | 202 ngx_http_upstream_ignore_header_line, 0, 0 }, |
201 | 203 |
204 { ngx_string("X-Accel-Charset"), | |
205 ngx_http_upstream_process_charset, 0, | |
206 ngx_http_upstream_ignore_header_line, 0, 0 }, | |
207 | |
202 #if (NGX_HTTP_GZIP) | 208 #if (NGX_HTTP_GZIP) |
203 { ngx_string("Content-Encoding"), | 209 { ngx_string("Content-Encoding"), |
204 ngx_http_upstream_process_header_line, | 210 ngx_http_upstream_process_header_line, |
205 offsetof(ngx_http_upstream_headers_in_t, content_encoding), | 211 offsetof(ngx_http_upstream_headers_in_t, content_encoding), |
206 ngx_http_upstream_copy_content_encoding, 0, 0 }, | 212 ngx_http_upstream_copy_content_encoding, 0, 0 }, |
1078 } | 1084 } |
1079 } | 1085 } |
1080 | 1086 |
1081 | 1087 |
1082 if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST | 1088 if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST |
1083 && u->conf->redirect_errors | 1089 && u->conf->intercept_errors |
1084 && r->err_ctx == NULL) | 1090 && r->err_ctx == NULL) |
1085 { | 1091 { |
1086 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 1092 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
1087 | 1093 |
1088 if (clcf->error_pages) { | 1094 if (clcf->error_pages) { |
1513 | 1519 |
1514 b = &u->buffer; | 1520 b = &u->buffer; |
1515 | 1521 |
1516 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 1522 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
1517 | 1523 |
1518 do_write = ev->write; | 1524 do_write = ev->write || u->length == 0; |
1519 | 1525 |
1520 for ( ;; ) { | 1526 for ( ;; ) { |
1521 | 1527 |
1522 if (do_write) { | 1528 if (do_write) { |
1523 | 1529 |
1557 if (size > u->length) { | 1563 if (size > u->length) { |
1558 size = u->length; | 1564 size = u->length; |
1559 } | 1565 } |
1560 | 1566 |
1561 if (size && u->peer.connection->read->ready) { | 1567 if (size && u->peer.connection->read->ready) { |
1568 | |
1562 n = u->peer.connection->recv(u->peer.connection, b->last, size); | 1569 n = u->peer.connection->recv(u->peer.connection, b->last, size); |
1563 | 1570 |
1564 if (n == NGX_AGAIN) { | 1571 if (n == NGX_AGAIN) { |
1565 break; | 1572 break; |
1566 } | 1573 } |
2124 return NGX_OK; | 2131 return NGX_OK; |
2125 } | 2132 } |
2126 | 2133 |
2127 | 2134 |
2128 static ngx_int_t | 2135 static ngx_int_t |
2136 ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h, | |
2137 ngx_uint_t offset) | |
2138 { | |
2139 r->headers_out.override_charset = &h->value; | |
2140 | |
2141 return NGX_OK; | |
2142 } | |
2143 | |
2144 | |
2145 static ngx_int_t | |
2129 ngx_http_upstream_copy_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, | 2146 ngx_http_upstream_copy_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, |
2130 ngx_uint_t offset) | 2147 ngx_uint_t offset) |
2131 { | 2148 { |
2132 ngx_table_elt_t *ho, **ph; | 2149 ngx_table_elt_t *ho, **ph; |
2133 | 2150 |
2182 | 2199 |
2183 static ngx_int_t | 2200 static ngx_int_t |
2184 ngx_http_upstream_copy_content_type(ngx_http_request_t *r, ngx_table_elt_t *h, | 2201 ngx_http_upstream_copy_content_type(ngx_http_request_t *r, ngx_table_elt_t *h, |
2185 ngx_uint_t offset) | 2202 ngx_uint_t offset) |
2186 { | 2203 { |
2204 u_char *p, *last; | |
2205 | |
2206 r->headers_out.content_type_len = h->value.len; | |
2187 r->headers_out.content_type = h->value; | 2207 r->headers_out.content_type = h->value; |
2208 | |
2209 for (p = h->value.data; *p; p++) { | |
2210 | |
2211 if (*p != ';') { | |
2212 continue; | |
2213 } | |
2214 | |
2215 last = p; | |
2216 | |
2217 while (*++p == ' ') { /* void */ } | |
2218 | |
2219 if (ngx_strncasecmp(p, "charset=", 8) != 0) { | |
2220 continue; | |
2221 } | |
2222 | |
2223 p += 8; | |
2224 | |
2225 r->headers_out.content_type_len = last - h->value.data; | |
2226 | |
2227 r->headers_out.charset.len = h->value.data + h->value.len - p; | |
2228 r->headers_out.charset.data = p; | |
2229 } | |
2188 | 2230 |
2189 return NGX_OK; | 2231 return NGX_OK; |
2190 } | 2232 } |
2191 | 2233 |
2192 | 2234 |