Mercurial > hg > nginx-vendor-1-0
comparison src/http/ngx_http_upstream.c @ 638:692f4d4d7f10 NGINX_1_0_9
nginx 1.0.9
*) Change: now the 0x7F-0x1F characters are escaped as \xXX in an
access_log.
*) Change: now SIGWINCH signal works only in daemon mode.
*) 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.
*) Feature: accept filters are now supported on NetBSD.
*) Feature: the "uwsgi_buffering" and "scgi_buffering" directives.
Thanks to Peter Smit.
*) Bugfix: a segmentation fault occurred on start or while
reconfiguration if the "ssl" directive was used at http level and
there was no "ssl_certificate" defined.
*) 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.
*) Bugfix: non-cacheable responses might be cached if
"proxy_cache_bypass" directive was used.
Thanks to John Ferlito.
*) Bugfix: cached responses with an empty body were returned
incorrectly; the bug had appeared in 0.8.31.
*) Bugfix: 201 responses of the ngx_http_dav_module were incorrect; the
bug had appeared in 0.8.32.
*) Bugfix: in the "return" directive.
*) Bugfix: the "ssl_verify_client", "ssl_verify_depth", and
"ssl_prefer_server_ciphers" directives might work incorrectly if SNI
was used.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 01 Nov 2011 00:00:00 +0400 |
parents | 65fd8be45530 |
children | 1b80544421e8 |
comparison
equal
deleted
inserted
replaced
637:ea7441793bba | 638:692f4d4d7f10 |
---|---|
358 | 358 |
359 | 359 |
360 ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[] = { | 360 ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[] = { |
361 { ngx_string("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT }, | 361 { ngx_string("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT }, |
362 { ngx_string("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES }, | 362 { ngx_string("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES }, |
363 { ngx_string("X-Accel-Limit-Rate"), NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE }, | |
364 { ngx_string("X-Accel-Buffering"), NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING }, | |
365 { ngx_string("X-Accel-Charset"), NGX_HTTP_UPSTREAM_IGN_XA_CHARSET }, | |
363 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES }, | 366 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES }, |
364 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL }, | 367 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL }, |
365 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE }, | 368 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE }, |
366 { ngx_null_string, 0 } | 369 { ngx_null_string, 0 } |
367 }; | 370 }; |
670 | 673 |
671 r->cache = NULL; | 674 r->cache = NULL; |
672 return NGX_DECLINED; | 675 return NGX_DECLINED; |
673 } | 676 } |
674 | 677 |
678 u->cacheable = 1; | |
679 | |
675 switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) { | 680 switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) { |
676 | 681 |
677 case NGX_ERROR: | 682 case NGX_ERROR: |
678 return NGX_ERROR; | 683 return NGX_ERROR; |
679 | 684 |
682 return NGX_DECLINED; | 687 return NGX_DECLINED; |
683 | 688 |
684 default: /* NGX_OK */ | 689 default: /* NGX_OK */ |
685 break; | 690 break; |
686 } | 691 } |
687 | |
688 u->cacheable = 1; | |
689 | 692 |
690 c = r->cache; | 693 c = r->cache; |
691 | 694 |
692 c->min_uses = u->conf->cache_min_uses; | 695 c->min_uses = u->conf->cache_min_uses; |
693 c->body_start = u->conf->buffer_size; | 696 c->body_start = u->conf->buffer_size; |
985 ev->error = 1; | 988 ev->error = 1; |
986 } | 989 } |
987 | 990 |
988 if (!u->cacheable && u->peer.connection) { | 991 if (!u->cacheable && u->peer.connection) { |
989 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, | 992 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, |
990 "kevent() reported that client closed prematurely " | 993 "kevent() reported that client prematurely closed " |
991 "connection, so upstream connection is closed too"); | 994 "connection, so upstream connection is closed too"); |
992 ngx_http_upstream_finalize_request(r, u, | 995 ngx_http_upstream_finalize_request(r, u, |
993 NGX_HTTP_CLIENT_CLOSED_REQUEST); | 996 NGX_HTTP_CLIENT_CLOSED_REQUEST); |
994 return; | 997 return; |
995 } | 998 } |
996 | 999 |
997 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, | 1000 ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno, |
998 "kevent() reported that client closed " | 1001 "kevent() reported that client prematurely closed " |
999 "prematurely connection"); | 1002 "connection"); |
1000 | 1003 |
1001 if (u->peer.connection == NULL) { | 1004 if (u->peer.connection == NULL) { |
1002 ngx_http_upstream_finalize_request(r, u, | 1005 ngx_http_upstream_finalize_request(r, u, |
1003 NGX_HTTP_CLIENT_CLOSED_REQUEST); | 1006 NGX_HTTP_CLIENT_CLOSED_REQUEST); |
1004 } | 1007 } |
1048 ev->eof = 1; | 1051 ev->eof = 1; |
1049 c->error = 1; | 1052 c->error = 1; |
1050 | 1053 |
1051 if (!u->cacheable && u->peer.connection) { | 1054 if (!u->cacheable && u->peer.connection) { |
1052 ngx_log_error(NGX_LOG_INFO, ev->log, err, | 1055 ngx_log_error(NGX_LOG_INFO, ev->log, err, |
1053 "client closed prematurely connection, " | 1056 "client prematurely closed connection, " |
1054 "so upstream connection is closed too"); | 1057 "so upstream connection is closed too"); |
1055 ngx_http_upstream_finalize_request(r, u, | 1058 ngx_http_upstream_finalize_request(r, u, |
1056 NGX_HTTP_CLIENT_CLOSED_REQUEST); | 1059 NGX_HTTP_CLIENT_CLOSED_REQUEST); |
1057 return; | 1060 return; |
1058 } | 1061 } |
1059 | 1062 |
1060 ngx_log_error(NGX_LOG_INFO, ev->log, err, | 1063 ngx_log_error(NGX_LOG_INFO, ev->log, err, |
1061 "client closed prematurely connection"); | 1064 "client prematurely closed connection"); |
1062 | 1065 |
1063 if (u->peer.connection == NULL) { | 1066 if (u->peer.connection == NULL) { |
1064 ngx_http_upstream_finalize_request(r, u, | 1067 ngx_http_upstream_finalize_request(r, u, |
1065 NGX_HTTP_CLIENT_CLOSED_REQUEST); | 1068 NGX_HTTP_CLIENT_CLOSED_REQUEST); |
1066 } | 1069 } |
2152 | 2155 |
2153 if (ngx_http_file_cache_create(r) != NGX_OK) { | 2156 if (ngx_http_file_cache_create(r) != NGX_OK) { |
2154 ngx_http_upstream_finalize_request(r, u, 0); | 2157 ngx_http_upstream_finalize_request(r, u, 0); |
2155 return; | 2158 return; |
2156 } | 2159 } |
2157 | |
2158 u->cacheable = 1; | |
2159 } | 2160 } |
2160 | 2161 |
2161 break; | 2162 break; |
2162 } | 2163 } |
2163 | 2164 |
3025 return; | 3026 return; |
3026 } | 3027 } |
3027 | 3028 |
3028 r->connection->log->action = "sending to client"; | 3029 r->connection->log->action = "sending to client"; |
3029 | 3030 |
3030 if (rc == 0) { | 3031 if (rc == 0 |
3032 #if (NGX_HTTP_CACHE) | |
3033 && !r->cached | |
3034 #endif | |
3035 ) | |
3036 { | |
3031 rc = ngx_http_send_special(r, NGX_HTTP_LAST); | 3037 rc = ngx_http_send_special(r, NGX_HTTP_LAST); |
3032 } | 3038 } |
3033 | 3039 |
3034 ngx_http_finalize_request(r, rc); | 3040 ngx_http_finalize_request(r, rc); |
3035 } | 3041 } |
3263 | 3269 |
3264 static ngx_int_t | 3270 static ngx_int_t |
3265 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, | 3271 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, |
3266 ngx_uint_t offset) | 3272 ngx_uint_t offset) |
3267 { | 3273 { |
3268 ngx_int_t n; | 3274 ngx_int_t n; |
3269 | 3275 ngx_http_upstream_t *u; |
3270 r->upstream->headers_in.x_accel_limit_rate = h; | 3276 |
3277 u = r->upstream; | |
3278 u->headers_in.x_accel_limit_rate = h; | |
3279 | |
3280 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE) { | |
3281 return NGX_OK; | |
3282 } | |
3271 | 3283 |
3272 n = ngx_atoi(h->value.data, h->value.len); | 3284 n = ngx_atoi(h->value.data, h->value.len); |
3273 | 3285 |
3274 if (n != NGX_ERROR) { | 3286 if (n != NGX_ERROR) { |
3275 r->limit_rate = (size_t) n; | 3287 r->limit_rate = (size_t) n; |
3281 | 3293 |
3282 static ngx_int_t | 3294 static ngx_int_t |
3283 ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h, | 3295 ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h, |
3284 ngx_uint_t offset) | 3296 ngx_uint_t offset) |
3285 { | 3297 { |
3286 u_char c0, c1, c2; | 3298 u_char c0, c1, c2; |
3287 | 3299 ngx_http_upstream_t *u; |
3288 if (r->upstream->conf->change_buffering) { | 3300 |
3301 u = r->upstream; | |
3302 | |
3303 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING) { | |
3304 return NGX_OK; | |
3305 } | |
3306 | |
3307 if (u->conf->change_buffering) { | |
3289 | 3308 |
3290 if (h->value.len == 2) { | 3309 if (h->value.len == 2) { |
3291 c0 = ngx_tolower(h->value.data[0]); | 3310 c0 = ngx_tolower(h->value.data[0]); |
3292 c1 = ngx_tolower(h->value.data[1]); | 3311 c1 = ngx_tolower(h->value.data[1]); |
3293 | 3312 |
3294 if (c0 == 'n' && c1 == 'o') { | 3313 if (c0 == 'n' && c1 == 'o') { |
3295 r->upstream->buffering = 0; | 3314 u->buffering = 0; |
3296 } | 3315 } |
3297 | 3316 |
3298 } else if (h->value.len == 3) { | 3317 } else if (h->value.len == 3) { |
3299 c0 = ngx_tolower(h->value.data[0]); | 3318 c0 = ngx_tolower(h->value.data[0]); |
3300 c1 = ngx_tolower(h->value.data[1]); | 3319 c1 = ngx_tolower(h->value.data[1]); |
3301 c2 = ngx_tolower(h->value.data[2]); | 3320 c2 = ngx_tolower(h->value.data[2]); |
3302 | 3321 |
3303 if (c0 == 'y' && c1 == 'e' && c2 == 's') { | 3322 if (c0 == 'y' && c1 == 'e' && c2 == 's') { |
3304 r->upstream->buffering = 1; | 3323 u->buffering = 1; |
3305 } | 3324 } |
3306 } | 3325 } |
3307 } | 3326 } |
3308 | 3327 |
3309 return NGX_OK; | 3328 return NGX_OK; |
3312 | 3331 |
3313 static ngx_int_t | 3332 static ngx_int_t |
3314 ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h, | 3333 ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h, |
3315 ngx_uint_t offset) | 3334 ngx_uint_t offset) |
3316 { | 3335 { |
3336 if (r->upstream->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_CHARSET) { | |
3337 return NGX_OK; | |
3338 } | |
3339 | |
3317 r->headers_out.override_charset = &h->value; | 3340 r->headers_out.override_charset = &h->value; |
3318 | 3341 |
3319 return NGX_OK; | 3342 return NGX_OK; |
3320 } | 3343 } |
3321 | 3344 |