Mercurial > hg > nginx
comparison 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 |
comparison
equal
deleted
inserted
replaced
451:f40362e47689 | 452:23fb87bddda1 |
---|---|
113 | 113 |
114 | 114 |
115 static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) | 115 static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) |
116 { | 116 { |
117 size_t len; | 117 size_t len; |
118 ngx_int_t escape; | |
118 ngx_uint_t i; | 119 ngx_uint_t i; |
119 ngx_buf_t *b; | 120 ngx_buf_t *b; |
120 ngx_chain_t *chain; | 121 ngx_chain_t *chain; |
121 ngx_list_part_t *part; | 122 ngx_list_part_t *part; |
122 ngx_table_elt_t *header; | 123 ngx_table_elt_t *header; |
131 | 132 |
132 } else { | 133 } else { |
133 len = r->method_name.len; | 134 len = r->method_name.len; |
134 } | 135 } |
135 | 136 |
137 if (r->quoted_uri) { | |
138 escape = 2 * ngx_escape_uri(NULL, r->uri.data + uc->location->len, | |
139 r->uri.len - uc->location->len); | |
140 } else { | |
141 escape = 0; | |
142 } | |
143 | |
136 len += uc->uri.len | 144 len += uc->uri.len |
137 + r->uri.len - uc->location->len | 145 + r->uri.len - uc->location->len + escape |
138 + 1 + r->args.len /* 1 is for "?" */ | 146 + 1 + r->args.len /* 1 is for "?" */ |
139 + sizeof(http_version) - 1 | 147 + sizeof(http_version) - 1 |
140 + sizeof(connection_close_header) - 1 | 148 + sizeof(connection_close_header) - 1 |
141 + 2; /* 2 is for "\r\n" at the header end */ | 149 + 2; /* 2 is for "\r\n" at the header end */ |
142 | |
143 | 150 |
144 if (p->lcf->preserve_host && r->headers_in.host) { | 151 if (p->lcf->preserve_host && r->headers_in.host) { |
145 len += sizeof(host_header) - 1 | 152 len += sizeof(host_header) - 1 |
146 + r->headers_in.host_name_len | 153 + r->headers_in.host_name_len |
147 + 1 /* 1 is for ":" */ | 154 + 1 /* 1 is for ":" */ |
216 b->last = ngx_cpymem(b->last, r->method_name.data, r->method_name.len); | 223 b->last = ngx_cpymem(b->last, r->method_name.data, r->method_name.len); |
217 } | 224 } |
218 | 225 |
219 b->last = ngx_cpymem(b->last, uc->uri.data, uc->uri.len); | 226 b->last = ngx_cpymem(b->last, uc->uri.data, uc->uri.len); |
220 | 227 |
221 b->last = ngx_cpymem(b->last, | 228 if (escape) { |
222 r->uri.data + uc->location->len, | 229 ngx_escape_uri(b->last, r->uri.data + uc->location->len, |
223 r->uri.len - uc->location->len); | 230 r->uri.len - uc->location->len); |
231 b->last += r->uri.len - uc->location->len + escape; | |
232 | |
233 } else { | |
234 b->last = ngx_cpymem(b->last, | |
235 r->uri.data + uc->location->len, | |
236 r->uri.len - uc->location->len); | |
237 } | |
224 | 238 |
225 if (r->args.len > 0) { | 239 if (r->args.len > 0) { |
226 *(b->last++) = '?'; | 240 *(b->last++) = '?'; |
227 b->last = ngx_cpymem(b->last, r->args.data, r->args.len); | 241 b->last = ngx_cpymem(b->last, r->args.data, r->args.len); |
228 } | 242 } |
420 return; | 434 return; |
421 } | 435 } |
422 | 436 |
423 p->upstream->output_chain_ctx = output; | 437 p->upstream->output_chain_ctx = output; |
424 | 438 |
425 output->sendfile = r->sendfile; | 439 output->sendfile = r->connection->sendfile; |
426 output->pool = r->pool; | 440 output->pool = r->pool; |
427 output->bufs.num = 1; | 441 output->bufs.num = 1; |
428 output->tag = (ngx_buf_tag_t) &ngx_http_proxy_module; | 442 output->tag = (ngx_buf_tag_t) &ngx_http_proxy_module; |
429 output->output_filter = (ngx_output_chain_filter_pt) ngx_chain_writer; | 443 output->output_filter = (ngx_output_chain_filter_pt) ngx_chain_writer; |
430 | 444 |
735 } | 749 } |
736 | 750 |
737 if (rc == NGX_AGAIN) { | 751 if (rc == NGX_AGAIN) { |
738 ngx_add_timer(c->write, p->lcf->send_timeout); | 752 ngx_add_timer(c->write, p->lcf->send_timeout); |
739 | 753 |
740 c->write->available = /* STUB: lowat */ 0; | 754 if (ngx_handle_write_event(c->write, p->lcf->send_lowat) == NGX_ERROR) { |
741 if (ngx_handle_write_event(c->write, NGX_LOWAT_EVENT) == NGX_ERROR) { | |
742 ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); | 755 ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); |
743 return; | 756 return; |
744 } | 757 } |
745 | 758 |
746 return; | 759 return; |
1170 ngx_http_core_loc_conf_t *clcf; | 1183 ngx_http_core_loc_conf_t *clcf; |
1171 | 1184 |
1172 r = p->request; | 1185 r = p->request; |
1173 | 1186 |
1174 r->headers_out.status = p->upstream->status; | 1187 r->headers_out.status = p->upstream->status; |
1188 r->headers_out.status_line = p->upstream->status_line; | |
1175 | 1189 |
1176 #if 0 | 1190 #if 0 |
1177 r->headers_out.content_length_n = -1; | 1191 r->headers_out.content_length_n = -1; |
1178 r->headers_out.content_length = NULL; | 1192 r->headers_out.content_length = NULL; |
1179 #endif | 1193 #endif |
1296 * because the writing a new data can interfere with sendfile() | 1310 * because the writing a new data can interfere with sendfile() |
1297 * that uses the same kernel file pages (at least on FreeBSD) | 1311 * that uses the same kernel file pages (at least on FreeBSD) |
1298 */ | 1312 */ |
1299 | 1313 |
1300 ep->cyclic_temp_file = 1; | 1314 ep->cyclic_temp_file = 1; |
1301 r->sendfile = 0; | 1315 r->connection->sendfile = 0; |
1302 | 1316 |
1303 } else { | 1317 } else { |
1304 ep->cyclic_temp_file = 0; | 1318 ep->cyclic_temp_file = 0; |
1305 r->sendfile = 1; | |
1306 } | 1319 } |
1307 | 1320 |
1308 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 1321 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
1309 | 1322 |
1310 ep->read_timeout = p->lcf->read_timeout; | 1323 ep->read_timeout = p->lcf->read_timeout; |