diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2006-06-28 16:00:26 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2006-06-28 16:00:26 +0000 |
| commit | ef809b86c36a9584a15df6caac2eb727ceacc10d (patch) | |
| tree | 80dc756ea197b259b159fb9a47b09df1a1eae7f1 /src/http/ngx_http_upstream.c | |
| parent | f115ebe9c3d57c0b271b03ed931ff42cdef37eb2 (diff) | |
| download | nginx-release-0.3.50.tar.gz nginx-release-0.3.50.tar.bz2 | |
nginx-0.3.50-RELEASE importrelease-0.3.50
*) 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.
Diffstat (limited to '')
| -rw-r--r-- | src/http/ngx_http_upstream.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index e53d32c1b..cf9d27b70 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -49,6 +49,8 @@ static ngx_int_t ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, ngx_uint_t offset); static ngx_int_t ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h, ngx_uint_t offset); +static ngx_int_t ngx_http_upstream_process_charset(ngx_http_request_t *r, + ngx_table_elt_t *h, ngx_uint_t offset); static ngx_int_t ngx_http_upstream_copy_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, ngx_uint_t offset); static ngx_int_t @@ -199,6 +201,10 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = { ngx_http_upstream_process_buffering, 0, ngx_http_upstream_ignore_header_line, 0, 0 }, + { ngx_string("X-Accel-Charset"), + ngx_http_upstream_process_charset, 0, + ngx_http_upstream_ignore_header_line, 0, 0 }, + #if (NGX_HTTP_GZIP) { ngx_string("Content-Encoding"), ngx_http_upstream_process_header_line, @@ -1080,7 +1086,7 @@ ngx_http_upstream_process_header(ngx_event_t *rev) if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST - && u->conf->redirect_errors + && u->conf->intercept_errors && r->err_ctx == NULL) { clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); @@ -1515,7 +1521,7 @@ ngx_http_upstream_process_non_buffered_body(ngx_event_t *ev) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - do_write = ev->write; + do_write = ev->write || u->length == 0; for ( ;; ) { @@ -1559,6 +1565,7 @@ ngx_http_upstream_process_non_buffered_body(ngx_event_t *ev) } if (size && u->peer.connection->read->ready) { + n = u->peer.connection->recv(u->peer.connection, b->last, size); if (n == NGX_AGAIN) { @@ -2126,6 +2133,16 @@ ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h, static ngx_int_t +ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h, + ngx_uint_t offset) +{ + r->headers_out.override_charset = &h->value; + + return NGX_OK; +} + + +static ngx_int_t ngx_http_upstream_copy_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, ngx_uint_t offset) { @@ -2184,8 +2201,33 @@ static ngx_int_t ngx_http_upstream_copy_content_type(ngx_http_request_t *r, ngx_table_elt_t *h, ngx_uint_t offset) { + u_char *p, *last; + + r->headers_out.content_type_len = h->value.len; r->headers_out.content_type = h->value; + for (p = h->value.data; *p; p++) { + + if (*p != ';') { + continue; + } + + last = p; + + while (*++p == ' ') { /* void */ } + + if (ngx_strncasecmp(p, "charset=", 8) != 0) { + continue; + } + + p += 8; + + r->headers_out.content_type_len = last - h->value.data; + + r->headers_out.charset.len = h->value.data + h->value.len - p; + r->headers_out.charset.data = p; + } + return NGX_OK; } |
