comparison src/http/ngx_http_upstream.c @ 438:ce4f9ff90bfa NGINX_0_7_31

nginx 0.7.31 *) Change: now the "try_files" directive tests files only and ignores directories. *) Feature: the "fastcgi_split_path_info" directive. *) Bugfixes in an "Expect" request header line support. *) Bugfixes in geo ranges. *) Bugfix: in a miss case ngx_http_memcached_module returned the "END" line as response body instead of default 404 page body; the bug had appeared in 0.7.18. Thanks to Maxim Dounin. *) Bugfix: while SMTP proxying nginx issued message "250 2.0.0 OK" instead of "235 2.0.0 OK"; the bug had appeared in 0.7.22. Thanks to Maxim Dounin.
author Igor Sysoev <http://sysoev.ru>
date Mon, 19 Jan 2009 00:00:00 +0300
parents 49a0eb7ce20c
children 6281966854a5
comparison
equal deleted inserted replaced
437:5da91f7cde93 438:ce4f9ff90bfa
1439 if (u->peer.tries > 1 && (u->conf->next_upstream & un->mask)) { 1439 if (u->peer.tries > 1 && (u->conf->next_upstream & un->mask)) {
1440 ngx_http_upstream_next(r, u, un->mask); 1440 ngx_http_upstream_next(r, u, un->mask);
1441 return NGX_OK; 1441 return NGX_OK;
1442 } 1442 }
1443 1443
1444 if (status == NGX_HTTP_NOT_FOUND && u->conf->intercept_404) {
1445 ngx_http_upstream_finalize_request(r, u, NGX_HTTP_NOT_FOUND);
1446 return NGX_OK;
1447 }
1448
1449 #if (NGX_HTTP_CACHE) 1444 #if (NGX_HTTP_CACHE)
1450 1445
1451 if (u->peer.tries == 0 && u->stale && (u->conf->use_stale & un->mask)) { 1446 if (u->peer.tries == 0 && u->stale && (u->conf->use_stale & un->mask)) {
1452 ngx_http_upstream_finalize_request(r, u, 1447 ngx_http_upstream_finalize_request(r, u,
1453 ngx_http_send_cached_response(r)); 1448 ngx_http_send_cached_response(r));
1469 ngx_uint_t i; 1464 ngx_uint_t i;
1470 ngx_table_elt_t *h; 1465 ngx_table_elt_t *h;
1471 ngx_http_err_page_t *err_page; 1466 ngx_http_err_page_t *err_page;
1472 ngx_http_core_loc_conf_t *clcf; 1467 ngx_http_core_loc_conf_t *clcf;
1473 1468
1469 status = u->headers_in.status_n;
1470
1471 if (status == NGX_HTTP_NOT_FOUND && u->conf->intercept_404) {
1472 ngx_http_upstream_finalize_request(r, u, NGX_HTTP_NOT_FOUND);
1473 return NGX_OK;
1474 }
1475
1474 if (!u->conf->intercept_errors) { 1476 if (!u->conf->intercept_errors) {
1475 return NGX_DECLINED; 1477 return NGX_DECLINED;
1476 } 1478 }
1477 1479
1478 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 1480 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1479 1481
1480 if (clcf->error_pages == NULL) { 1482 if (clcf->error_pages == NULL) {
1481 return NGX_DECLINED; 1483 return NGX_DECLINED;
1482 } 1484 }
1483
1484 status = u->headers_in.status_n;
1485 1485
1486 err_page = clcf->error_pages->elts; 1486 err_page = clcf->error_pages->elts;
1487 for (i = 0; i < clcf->error_pages->nelts; i++) { 1487 for (i = 0; i < clcf->error_pages->nelts; i++) {
1488 1488
1489 if (err_page[i].status == status) { 1489 if (err_page[i].status == status) {
2199 2199
2200 2200
2201 static void 2201 static void
2202 ngx_http_upstream_process_request(ngx_http_request_t *r) 2202 ngx_http_upstream_process_request(ngx_http_request_t *r)
2203 { 2203 {
2204 ngx_uint_t del;
2204 ngx_temp_file_t *tf; 2205 ngx_temp_file_t *tf;
2205 ngx_event_pipe_t *p; 2206 ngx_event_pipe_t *p;
2206 ngx_http_upstream_t *u; 2207 ngx_http_upstream_t *u;
2207 2208
2208 u = r->upstream; 2209 u = r->upstream;
2210 2211
2211 if (u->peer.connection) { 2212 if (u->peer.connection) {
2212 2213
2213 if (u->store) { 2214 if (u->store) {
2214 2215
2216 del = p->upstream_error;
2217
2215 tf = u->pipe->temp_file; 2218 tf = u->pipe->temp_file;
2216 2219
2217 if (p->upstream_eof 2220 if (p->upstream_eof) {
2218 && u->headers_in.status_n == NGX_HTTP_OK 2221
2219 && (u->headers_in.content_length_n == -1 2222 if (u->headers_in.status_n == NGX_HTTP_OK
2220 || (u->headers_in.content_length_n == tf->offset))) 2223 && (u->headers_in.content_length_n == -1
2221 { 2224 || (u->headers_in.content_length_n == tf->offset)))
2222 ngx_http_upstream_store(r, u); 2225 {
2223 2226 ngx_http_upstream_store(r, u);
2224 } else if ((p->upstream_error 2227
2225 || (p->upstream_eof 2228 } else {
2226 && u->headers_in.status_n != NGX_HTTP_OK)) 2229 del = 1;
2227 && tf->file.fd != NGX_INVALID_FILE) 2230 }
2228 { 2231 }
2232
2233 if (del && tf->file.fd != NGX_INVALID_FILE) {
2234
2229 if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) { 2235 if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) {
2230 2236
2231 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, 2237 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
2232 ngx_delete_file_n " \"%s\" failed", 2238 ngx_delete_file_n " \"%s\" failed",
2233 u->pipe->temp_file->file.name.data); 2239 u->pipe->temp_file->file.name.data);