Mercurial > hg > nginx
diff src/http/modules/proxy/ngx_http_proxy_upstream.c @ 452:23fb87bddda1 release-0.1.1
nginx-0.1.1-RELEASE import
*) Feature: the gzip_types directive.
*) Feature: the tcp_nodelay directive.
*) Feature: the send_lowat directive is working not only on OSes that
support kqueue NOTE_LOWAT, but also on OSes that support SO_SNDLOWAT.
*) Feature: the setproctitle() emulation for Linux and Solaris.
*) Bugfix: the "Location" header rewrite bug fixed while the proxying.
*) Bugfix: the ngx_http_chunked_module module may get caught in an
endless loop.
*) Bugfix: the /dev/poll module bugs fixed.
*) Bugfix: the responses were corrupted when the temporary files were
used while the proxying.
*) Bugfix: the unescaped requests were passed to the backend.
*) Bugfix: while the build configuration on Linux 2.4 the
--with-poll_module parameter was required.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 11 Oct 2004 15:07:03 +0000 |
parents | 42d11f017717 |
children | 295d97d70c69 |
line wrap: on
line diff
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -115,6 +115,7 @@ int ngx_http_proxy_request_upstream(ngx_ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) { size_t len; + ngx_int_t escape; ngx_uint_t i; ngx_buf_t *b; ngx_chain_t *chain; @@ -133,14 +134,20 @@ static ngx_chain_t *ngx_http_proxy_creat len = r->method_name.len; } + if (r->quoted_uri) { + escape = 2 * ngx_escape_uri(NULL, r->uri.data + uc->location->len, + r->uri.len - uc->location->len); + } else { + escape = 0; + } + len += uc->uri.len - + r->uri.len - uc->location->len + + r->uri.len - uc->location->len + escape + 1 + r->args.len /* 1 is for "?" */ + sizeof(http_version) - 1 + sizeof(connection_close_header) - 1 + 2; /* 2 is for "\r\n" at the header end */ - if (p->lcf->preserve_host && r->headers_in.host) { len += sizeof(host_header) - 1 + r->headers_in.host_name_len @@ -218,9 +225,16 @@ static ngx_chain_t *ngx_http_proxy_creat b->last = ngx_cpymem(b->last, uc->uri.data, uc->uri.len); - b->last = ngx_cpymem(b->last, - r->uri.data + uc->location->len, - r->uri.len - uc->location->len); + if (escape) { + ngx_escape_uri(b->last, r->uri.data + uc->location->len, + r->uri.len - uc->location->len); + b->last += r->uri.len - uc->location->len + escape; + + } else { + b->last = ngx_cpymem(b->last, + r->uri.data + uc->location->len, + r->uri.len - uc->location->len); + } if (r->args.len > 0) { *(b->last++) = '?'; @@ -422,7 +436,7 @@ static void ngx_http_proxy_init_upstream p->upstream->output_chain_ctx = output; - output->sendfile = r->sendfile; + output->sendfile = r->connection->sendfile; output->pool = r->pool; output->bufs.num = 1; output->tag = (ngx_buf_tag_t) &ngx_http_proxy_module; @@ -737,8 +751,7 @@ static void ngx_http_proxy_send_request( if (rc == NGX_AGAIN) { ngx_add_timer(c->write, p->lcf->send_timeout); - c->write->available = /* STUB: lowat */ 0; - if (ngx_handle_write_event(c->write, NGX_LOWAT_EVENT) == NGX_ERROR) { + if (ngx_handle_write_event(c->write, p->lcf->send_lowat) == NGX_ERROR) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); return; } @@ -1172,6 +1185,7 @@ static void ngx_http_proxy_send_response r = p->request; r->headers_out.status = p->upstream->status; + r->headers_out.status_line = p->upstream->status_line; #if 0 r->headers_out.content_length_n = -1; @@ -1298,11 +1312,10 @@ static void ngx_http_proxy_send_response */ ep->cyclic_temp_file = 1; - r->sendfile = 0; + r->connection->sendfile = 0; } else { ep->cyclic_temp_file = 0; - r->sendfile = 1; } clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);