Mercurial > hg > nginx-vendor-current
comparison src/http/ngx_http_upstream.c @ 644:6f21ae02fb01 NGINX_1_1_6
nginx 1.1.6
*) Change in internal API: now module context data are cleared while
internal redirect to named location.
Requested by Yichun Zhang.
*) Change: if a server in an upstream failed, only one request will be
sent to it after fail_timeout; the server will be considered alive if
it will successfully respond to the request.
*) Change: now the 0x7F-0x1F characters are escaped as \xXX in an
access_log.
*) Feature: "proxy/fastcgi/scgi/uwsgi_ignore_headers" directives support
the following additional values: X-Accel-Limit-Rate,
X-Accel-Buffering, X-Accel-Charset.
*) Feature: decrease of memory consumption if SSL is used.
*) Bugfix: some UTF-8 characters were processed incorrectly.
Thanks to Alexey Kuts.
*) Bugfix: the ngx_http_rewrite_module directives specified at "server"
level were executed twice if no matching locations were defined.
*) Bugfix: a socket leak might occurred if "aio sendfile" was used.
*) Bugfix: connections with fast clients might be closed after
send_timeout if file AIO was used.
*) Bugfix: in the ngx_http_autoindex_module.
*) Bugfix: the module ngx_http_mp4_module did not support seeking on
32-bit platforms.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 17 Oct 2011 00:00:00 +0400 |
parents | d3cf6c6b0043 |
children | 4d05413aebad |
comparison
equal
deleted
inserted
replaced
643:a4bb0b481f6c | 644:6f21ae02fb01 |
---|---|
367 | 367 |
368 | 368 |
369 ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[] = { | 369 ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[] = { |
370 { ngx_string("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT }, | 370 { ngx_string("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT }, |
371 { ngx_string("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES }, | 371 { ngx_string("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES }, |
372 { ngx_string("X-Accel-Limit-Rate"), NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE }, | |
373 { ngx_string("X-Accel-Buffering"), NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING }, | |
374 { ngx_string("X-Accel-Charset"), NGX_HTTP_UPSTREAM_IGN_XA_CHARSET }, | |
372 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES }, | 375 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES }, |
373 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL }, | 376 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL }, |
374 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE }, | 377 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE }, |
375 { ngx_null_string, 0 } | 378 { ngx_null_string, 0 } |
376 }; | 379 }; |
997 ev->error = 1; | 1000 ev->error = 1; |
998 } | 1001 } |
999 | 1002 |
1000 if (!u->cacheable && u->peer.connection) { | 1003 if (!u->cacheable && u->peer.connection) { |
1001 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, | 1004 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, |
1002 "kevent() reported that client closed prematurely " | 1005 "kevent() reported that client prematurely closed " |
1003 "connection, so upstream connection is closed too"); | 1006 "connection, so upstream connection is closed too"); |
1004 ngx_http_upstream_finalize_request(r, u, | 1007 ngx_http_upstream_finalize_request(r, u, |
1005 NGX_HTTP_CLIENT_CLOSED_REQUEST); | 1008 NGX_HTTP_CLIENT_CLOSED_REQUEST); |
1006 return; | 1009 return; |
1007 } | 1010 } |
1008 | 1011 |
1009 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, | 1012 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, |
1010 "kevent() reported that client closed " | 1013 "kevent() reported that client prematurely closed " |
1011 "prematurely connection"); | 1014 "connection"); |
1012 | 1015 |
1013 if (u->peer.connection == NULL) { | 1016 if (u->peer.connection == NULL) { |
1014 ngx_http_upstream_finalize_request(r, u, | 1017 ngx_http_upstream_finalize_request(r, u, |
1015 NGX_HTTP_CLIENT_CLOSED_REQUEST); | 1018 NGX_HTTP_CLIENT_CLOSED_REQUEST); |
1016 } | 1019 } |
1060 ev->eof = 1; | 1063 ev->eof = 1; |
1061 c->error = 1; | 1064 c->error = 1; |
1062 | 1065 |
1063 if (!u->cacheable && u->peer.connection) { | 1066 if (!u->cacheable && u->peer.connection) { |
1064 ngx_log_error(NGX_LOG_INFO, ev->log, err, | 1067 ngx_log_error(NGX_LOG_INFO, ev->log, err, |
1065 "client closed prematurely connection, " | 1068 "client prematurely closed connection, " |
1066 "so upstream connection is closed too"); | 1069 "so upstream connection is closed too"); |
1067 ngx_http_upstream_finalize_request(r, u, | 1070 ngx_http_upstream_finalize_request(r, u, |
1068 NGX_HTTP_CLIENT_CLOSED_REQUEST); | 1071 NGX_HTTP_CLIENT_CLOSED_REQUEST); |
1069 return; | 1072 return; |
1070 } | 1073 } |
1071 | 1074 |
1072 ngx_log_error(NGX_LOG_INFO, ev->log, err, | 1075 ngx_log_error(NGX_LOG_INFO, ev->log, err, |
1073 "client closed prematurely connection"); | 1076 "client prematurely closed connection"); |
1074 | 1077 |
1075 if (u->peer.connection == NULL) { | 1078 if (u->peer.connection == NULL) { |
1076 ngx_http_upstream_finalize_request(r, u, | 1079 ngx_http_upstream_finalize_request(r, u, |
1077 NGX_HTTP_CLIENT_CLOSED_REQUEST); | 1080 NGX_HTTP_CLIENT_CLOSED_REQUEST); |
1078 } | 1081 } |
3326 | 3329 |
3327 static ngx_int_t | 3330 static ngx_int_t |
3328 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, | 3331 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, |
3329 ngx_uint_t offset) | 3332 ngx_uint_t offset) |
3330 { | 3333 { |
3331 ngx_int_t n; | 3334 ngx_int_t n; |
3332 | 3335 ngx_http_upstream_t *u; |
3333 r->upstream->headers_in.x_accel_limit_rate = h; | 3336 |
3337 u = r->upstream; | |
3338 u->headers_in.x_accel_limit_rate = h; | |
3339 | |
3340 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE) { | |
3341 return NGX_OK; | |
3342 } | |
3334 | 3343 |
3335 n = ngx_atoi(h->value.data, h->value.len); | 3344 n = ngx_atoi(h->value.data, h->value.len); |
3336 | 3345 |
3337 if (n != NGX_ERROR) { | 3346 if (n != NGX_ERROR) { |
3338 r->limit_rate = (size_t) n; | 3347 r->limit_rate = (size_t) n; |
3344 | 3353 |
3345 static ngx_int_t | 3354 static ngx_int_t |
3346 ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h, | 3355 ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h, |
3347 ngx_uint_t offset) | 3356 ngx_uint_t offset) |
3348 { | 3357 { |
3349 u_char c0, c1, c2; | 3358 u_char c0, c1, c2; |
3350 | 3359 ngx_http_upstream_t *u; |
3351 if (r->upstream->conf->change_buffering) { | 3360 |
3361 u = r->upstream; | |
3362 | |
3363 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING) { | |
3364 return NGX_OK; | |
3365 } | |
3366 | |
3367 if (u->conf->change_buffering) { | |
3352 | 3368 |
3353 if (h->value.len == 2) { | 3369 if (h->value.len == 2) { |
3354 c0 = ngx_tolower(h->value.data[0]); | 3370 c0 = ngx_tolower(h->value.data[0]); |
3355 c1 = ngx_tolower(h->value.data[1]); | 3371 c1 = ngx_tolower(h->value.data[1]); |
3356 | 3372 |
3357 if (c0 == 'n' && c1 == 'o') { | 3373 if (c0 == 'n' && c1 == 'o') { |
3358 r->upstream->buffering = 0; | 3374 u->buffering = 0; |
3359 } | 3375 } |
3360 | 3376 |
3361 } else if (h->value.len == 3) { | 3377 } else if (h->value.len == 3) { |
3362 c0 = ngx_tolower(h->value.data[0]); | 3378 c0 = ngx_tolower(h->value.data[0]); |
3363 c1 = ngx_tolower(h->value.data[1]); | 3379 c1 = ngx_tolower(h->value.data[1]); |
3364 c2 = ngx_tolower(h->value.data[2]); | 3380 c2 = ngx_tolower(h->value.data[2]); |
3365 | 3381 |
3366 if (c0 == 'y' && c1 == 'e' && c2 == 's') { | 3382 if (c0 == 'y' && c1 == 'e' && c2 == 's') { |
3367 r->upstream->buffering = 1; | 3383 u->buffering = 1; |
3368 } | 3384 } |
3369 } | 3385 } |
3370 } | 3386 } |
3371 | 3387 |
3372 return NGX_OK; | 3388 return NGX_OK; |
3375 | 3391 |
3376 static ngx_int_t | 3392 static ngx_int_t |
3377 ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h, | 3393 ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h, |
3378 ngx_uint_t offset) | 3394 ngx_uint_t offset) |
3379 { | 3395 { |
3396 if (r->upstream->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_CHARSET) { | |
3397 return NGX_OK; | |
3398 } | |
3399 | |
3380 r->headers_out.override_charset = &h->value; | 3400 r->headers_out.override_charset = &h->value; |
3381 | 3401 |
3382 return NGX_OK; | 3402 return NGX_OK; |
3383 } | 3403 } |
3384 | 3404 |