comparison src/http/modules/proxy/ngx_http_proxy_upstream.c @ 509:9b8c906f6e63 release-0.1.29

nginx-0.1.29-RELEASE import *) Feature: the ngx_http_ssi_module supports "include virtual" command. *) Feature: the ngx_http_ssi_module supports the condition command like 'if expr="$NAME"' and "else" and "endif" commands. Only one nested level is supported. *) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and DATE_GMT variables and "config timefmt" command. *) Feature: the "ssi_ignore_recycled_buffers" directive. *) Bugfix: the "echo" command did not show the default value for the empty QUERY_STRING variable. *) Change: the ngx_http_proxy_module was rewritten. *) Feature: the "proxy_redirect", "proxy_pass_request_headers", "proxy_pass_request_body", and "proxy_method" directives. *) Feature: the "proxy_set_header" directive. The "proxy_x_var" was canceled and must be replaced with the proxy_set_header directive. *) Change: the "proxy_preserve_host" is canceled and must be replaced with the "proxy_set_header Host $host" and the "proxy_redirect off" directives, the "proxy_set_header Host $host:$proxy_port" directive and the appropriate proxy_redirect directives. *) Change: the "proxy_set_x_real_ip" is canceled and must be replaced with the "proxy_set_header X-Real-IP $remote_addr" directive. *) Change: the "proxy_add_x_forwarded_for" is canceled and must be replaced with the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for" directive. *) Change: the "proxy_set_x_url" is canceled and must be replaced with the "proxy_set_header X-URL http://$host:$server_port$request_uri" directive. *) Feature: the "fastcgi_param" directive. *) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params" directive are canceled and must be replaced with the fastcgi_param directives. *) Feature: the "index" directive can use the variables. *) Feature: the "index" directive can be used at http and server levels. *) Change: the last index only in the "index" directive can be absolute. *) Feature: the "rewrite" directive can use the variables. *) Feature: the "internal" directive. *) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR, SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME, REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables. *) Change: nginx now passes the invalid lines in a client request headers or a backend response header. *) Bugfix: if the backend did not transfer response for a long time and the "send_timeout" was less than "proxy_read_timeout", then nginx returned the 408 response. *) Bugfix: the segmentation fault was occurred if the backend sent an invalid line in response header; the bug had appeared in 0.1.26. *) Bugfix: the segmentation fault may occurred in FastCGI fault tolerance configuration. *) Bugfix: the "expires" directive did not remove the previous "Expires" and "Cache-Control" headers. *) Bugfix: nginx did not take into account trailing dot in "Host" header line. *) Bugfix: the ngx_http_auth_module did not work under Linux. *) Bugfix: the rewrite directive worked incorrectly, if the arguments were in a request. *) Bugfix: nginx could not be built on MacOS X.
author Igor Sysoev <igor@sysoev.ru>
date Thu, 12 May 2005 14:58:06 +0000
parents ee66921ecd47
children
comparison
equal deleted inserted replaced
508:ca1020ce99ba 509:9b8c906f6e63
22 static void ngx_http_proxy_dummy_handler(ngx_event_t *wev); 22 static void ngx_http_proxy_dummy_handler(ngx_event_t *wev);
23 static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev); 23 static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev);
24 static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev); 24 static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev);
25 static ssize_t ngx_http_proxy_read_upstream_header(ngx_http_proxy_ctx_t *); 25 static ssize_t ngx_http_proxy_read_upstream_header(ngx_http_proxy_ctx_t *);
26 static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p); 26 static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p);
27 static void ngx_http_proxy_process_downstream(ngx_http_request_t *r);
27 static void ngx_http_proxy_process_body(ngx_event_t *ev); 28 static void ngx_http_proxy_process_body(ngx_event_t *ev);
28 static void ngx_http_proxy_next_upstream(ngx_http_proxy_ctx_t *p, 29 static void ngx_http_proxy_next_upstream(ngx_http_proxy_ctx_t *p,
29 ngx_uint_t ft_type); 30 ngx_uint_t ft_type);
30 31
31 32
110 111
111 if (p->upstream->method) { 112 if (p->upstream->method) {
112 len = http_methods[p->upstream->method - 1].len + uc->uri.len; 113 len = http_methods[p->upstream->method - 1].len + uc->uri.len;
113 114
114 } else { 115 } else {
115 len = r->method_name.len + uc->uri.len; 116 len = r->method_name.len + 1 + uc->uri.len;
116 } 117 }
117 118
118 if (p->lcf->pass_unparsed_uri && r->valid_unparsed_uri) { 119 if (p->lcf->pass_unparsed_uri && r->valid_unparsed_uri) {
119 len += r->unparsed_uri.len - 1; 120 len += r->unparsed_uri.len - 1;
120 121
259 if (p->upstream->method) { 260 if (p->upstream->method) {
260 b->last = ngx_cpymem(b->last, 261 b->last = ngx_cpymem(b->last,
261 http_methods[p->upstream->method - 1].data, 262 http_methods[p->upstream->method - 1].data,
262 http_methods[p->upstream->method - 1].len); 263 http_methods[p->upstream->method - 1].len);
263 } else { 264 } else {
264 b->last = ngx_cpymem(b->last, r->method_name.data, r->method_name.len); 265 b->last = ngx_cpymem(b->last, r->method_name.data,
266 r->method_name.len + 1);
265 } 267 }
266 268
267 b->last = ngx_cpymem(b->last, uc->uri.data, uc->uri.len); 269 b->last = ngx_cpymem(b->last, uc->uri.data, uc->uri.len);
268 270
269 if (p->lcf->pass_unparsed_uri && r->valid_unparsed_uri) { 271 if (p->lcf->pass_unparsed_uri && r->valid_unparsed_uri) {
500 502
501 if (r->connection->read->timer_set) { 503 if (r->connection->read->timer_set) {
502 ngx_del_timer(r->connection->read); 504 ngx_del_timer(r->connection->read);
503 } 505 }
504 506
505 r->connection->read->event_handler = ngx_http_proxy_check_broken_connection; 507 r->read_event_handler = ngx_http_proxy_rd_check_broken_connection;
506 508
507 if (ngx_event_flags & NGX_USE_CLEAR_EVENT) { 509 if (ngx_event_flags & NGX_USE_CLEAR_EVENT) {
508 510
509 r->connection->write->event_handler = 511 r->write_event_handler = ngx_http_proxy_wr_check_broken_connection;
510 ngx_http_proxy_check_broken_connection;
511 512
512 if (!r->connection->write->active) { 513 if (!r->connection->write->active) {
513 if (ngx_add_event(r->connection->write, NGX_WRITE_EVENT, 514 if (ngx_add_event(r->connection->write, NGX_WRITE_EVENT,
514 NGX_CLEAR_EVENT) == NGX_ERROR) 515 NGX_CLEAR_EVENT) == NGX_ERROR)
515 { 516 {
768 769
769 r = p->request; 770 r = p->request;
770 c = p->upstream->peer.connection; 771 c = p->upstream->peer.connection;
771 772
772 c->data = p; 773 c->data = p;
773 c->write->event_handler = ngx_http_proxy_send_request_handler; 774 c->write->handler = ngx_http_proxy_send_request_handler;
774 c->read->event_handler = ngx_http_proxy_process_upstream_status_line; 775 c->read->handler = ngx_http_proxy_process_upstream_status_line;
775 776
776 c->sendfile = r->connection->sendfile; 777 c->sendfile = r->connection->sendfile;
777 778
778 c->pool = r->pool; 779 c->pool = r->pool;
779 c->read->log = c->write->log = c->log = r->connection->log; 780 c->read->log = c->write->log = c->log = r->connection->log;
923 ngx_http_proxy_process_upstream_status_line(c->read); 924 ngx_http_proxy_process_upstream_status_line(c->read);
924 return; 925 return;
925 } 926 }
926 #endif 927 #endif
927 928
928 c->write->event_handler = ngx_http_proxy_dummy_handler; 929 c->write->handler = ngx_http_proxy_dummy_handler;
929 930
930 if (ngx_handle_level_write_event(c->write) == NGX_ERROR) { 931 if (ngx_handle_write_event(c->write, 0) == NGX_ERROR) {
931 ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); 932 ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
932 return; 933 return;
933 } 934 }
934 } 935 }
935 936
1122 return; 1123 return;
1123 } 1124 }
1124 } 1125 }
1125 1126
1126 1127
1127 c->read->event_handler = ngx_http_proxy_process_upstream_headers; 1128 c->read->handler = ngx_http_proxy_process_upstream_headers;
1128 ngx_http_proxy_process_upstream_headers(rev); 1129 ngx_http_proxy_process_upstream_headers(rev);
1129 } 1130 }
1130 1131
1131 1132
1132 static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev) 1133 static void ngx_http_proxy_process_upstream_headers(ngx_event_t *rev)
1172 } 1173 }
1173 } 1174 }
1174 1175
1175 rc = ngx_http_parse_header_line(p->request, p->header_in); 1176 rc = ngx_http_parse_header_line(p->request, p->header_in);
1176 1177
1177 if (rc == NGX_OK) { 1178 if (rc == NGX_OK && !r->invalid_header) {
1178 1179
1179 /* a header line has been parsed successfully */ 1180 /* a header line has been parsed successfully */
1180 1181
1181 h = ngx_list_push(&p->upstream->headers_in.headers); 1182 h = ngx_list_push(&p->upstream->headers_in.headers);
1182 if (h == NULL) { 1183 if (h == NULL) {
1238 1239
1239 ngx_http_proxy_send_response(p); 1240 ngx_http_proxy_send_response(p);
1240 return; 1241 return;
1241 1242
1242 } else if (rc != NGX_AGAIN) { 1243 } else if (rc != NGX_AGAIN) {
1244
1245 if (r->invalid_header) {
1246 rc = NGX_HTTP_PARSE_INVALID_HEADER;
1247 }
1243 1248
1244 /* there was error while a header line parsing */ 1249 /* there was error while a header line parsing */
1245 1250
1246 ngx_log_error(NGX_LOG_ERR, rev->log, 0, 1251 ngx_log_error(NGX_LOG_ERR, rev->log, 0,
1247 upstream_header_errors[rc - NGX_HTTP_PARSE_HEADER_ERROR]); 1252 upstream_header_errors[rc - NGX_HTTP_PARSE_HEADER_ERROR]);
1463 1468
1464 ep->read_timeout = p->lcf->read_timeout; 1469 ep->read_timeout = p->lcf->read_timeout;
1465 ep->send_timeout = clcf->send_timeout; 1470 ep->send_timeout = clcf->send_timeout;
1466 ep->send_lowat = clcf->send_lowat; 1471 ep->send_lowat = clcf->send_lowat;
1467 1472
1468 p->upstream->peer.connection->read->event_handler = 1473 p->upstream->peer.connection->read->handler = ngx_http_proxy_process_body;
1469 ngx_http_proxy_process_body; 1474 r->write_event_handler = ngx_http_proxy_process_downstream;
1470 r->connection->write->event_handler = ngx_http_proxy_process_body;
1471 1475
1472 ngx_http_proxy_process_body(p->upstream->peer.connection->read); 1476 ngx_http_proxy_process_body(p->upstream->peer.connection->read);
1473 1477
1474 return; 1478 return;
1479 }
1480
1481
1482 static void ngx_http_proxy_process_downstream(ngx_http_request_t *r)
1483 {
1484 ngx_http_proxy_process_body(r->connection->write);
1475 } 1485 }
1476 1486
1477 1487
1478 static void ngx_http_proxy_process_body(ngx_event_t *ev) 1488 static void ngx_http_proxy_process_body(ngx_event_t *ev)
1479 { 1489 {