comparison src/http/ngx_http_upstream.c @ 1885:e5897822515f

test response length in proxy/fastcgi_store
author Igor Sysoev <igor@sysoev.ru>
date Mon, 11 Feb 2008 13:14:56 +0000
parents edaea30d83be
children 37f4020963dc
comparison
equal deleted inserted replaced
1884:7756b1085119 1885:e5897822515f
1350 } 1350 }
1351 1351
1352 r->headers_out.status = u->headers_in.status_n; 1352 r->headers_out.status = u->headers_in.status_n;
1353 r->headers_out.status_line = u->headers_in.status_line; 1353 r->headers_out.status_line = u->headers_in.status_line;
1354 1354
1355 u->headers_in.content_length_n = r->headers_out.content_length_n;
1356
1355 if (r->headers_out.content_length_n != -1) { 1357 if (r->headers_out.content_length_n != -1) {
1356 u->length = (size_t) r->headers_out.content_length_n; 1358 u->length = (size_t) r->headers_out.content_length_n;
1357 1359
1358 } else { 1360 } else {
1359 u->length = NGX_MAX_SIZE_T_VALUE; 1361 u->length = NGX_MAX_SIZE_T_VALUE;
1953 1955
1954 1956
1955 static void 1957 static void
1956 ngx_http_upstream_process_body(ngx_event_t *ev) 1958 ngx_http_upstream_process_body(ngx_event_t *ev)
1957 { 1959 {
1960 ngx_temp_file_t *tf;
1958 ngx_event_pipe_t *p; 1961 ngx_event_pipe_t *p;
1959 ngx_connection_t *c, *downstream; 1962 ngx_connection_t *c, *downstream;
1960 ngx_http_log_ctx_t *ctx; 1963 ngx_http_log_ctx_t *ctx;
1961 ngx_http_request_t *r; 1964 ngx_http_request_t *r;
1962 ngx_http_upstream_t *u; 1965 ngx_http_upstream_t *u;
2047 2050
2048 if (u->peer.connection) { 2051 if (u->peer.connection) {
2049 2052
2050 if (u->store) { 2053 if (u->store) {
2051 2054
2052 if (p->upstream_eof && u->headers_in.status_n == NGX_HTTP_OK) { 2055 tf = u->pipe->temp_file;
2053 2056
2057 if (p->upstream_eof
2058 && u->headers_in.status_n == NGX_HTTP_OK
2059 && (u->headers_in.content_length_n == -1
2060 || (u->headers_in.content_length_n == tf->offset)))
2061 {
2054 ngx_http_upstream_store(r, u); 2062 ngx_http_upstream_store(r, u);
2055 2063
2056 } else if ((p->upstream_error 2064 } else if ((p->upstream_error
2057 || (p->upstream_eof 2065 || (p->upstream_eof
2058 && u->headers_in.status_n != NGX_HTTP_OK)) 2066 && u->headers_in.status_n != NGX_HTTP_OK))
2059 && u->pipe->temp_file->file.fd != NGX_INVALID_FILE) 2067 && tf->file.fd != NGX_INVALID_FILE)
2060 { 2068 {
2061 if (ngx_delete_file(u->pipe->temp_file->file.name.data) 2069 if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) {
2062 == NGX_FILE_ERROR) 2070
2063 {
2064 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, 2071 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
2065 ngx_delete_file_n " \"%s\" failed", 2072 ngx_delete_file_n " \"%s\" failed",
2066 u->pipe->temp_file->file.name.data); 2073 u->pipe->temp_file->file.name.data);
2067 } 2074 }
2068 } 2075 }