summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-05-04 10:04:21 +0000
committerIgor Sysoev <igor@sysoev.ru>2008-05-04 10:04:21 +0000
commita3c1ad81eba455337a86b915dafd9d168c099f28 (patch)
treedf8af0d908d806c0f68120a1c30e835c4a281e86
parent45519cb5f4617577ed5793dce11fec8fe62ebdf2 (diff)
downloadnginx-a3c1ad81eba455337a86b915dafd9d168c099f28.tar.gz
r1886 merge:
test response length in proxy/fastcgi_store
-rw-r--r--src/http/ngx_http_upstream.c17
-rw-r--r--src/http/ngx_http_upstream.h2
2 files changed, 14 insertions, 5 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index f4daf401d..e430d1a0e 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1235,6 +1235,8 @@ ngx_http_upstream_process_header(ngx_event_t *rev)
r->headers_out.status = u->headers_in.status_n;
r->headers_out.status_line = u->headers_in.status_line;
+ u->headers_in.content_length_n = r->headers_out.content_length_n;
+
if (r->headers_out.content_length_n != -1) {
u->length = (size_t) r->headers_out.content_length_n;
@@ -1838,6 +1840,7 @@ ngx_http_upstream_process_downstream(ngx_http_request_t *r)
static void
ngx_http_upstream_process_body(ngx_event_t *ev)
{
+ ngx_temp_file_t *tf;
ngx_event_pipe_t *p;
ngx_connection_t *c, *downstream;
ngx_http_log_ctx_t *ctx;
@@ -1932,18 +1935,22 @@ ngx_http_upstream_process_body(ngx_event_t *ev)
if (u->store) {
- if (p->upstream_eof && u->headers_in.status_n == NGX_HTTP_OK) {
+ tf = u->pipe->temp_file;
+ if (p->upstream_eof
+ && u->headers_in.status_n == NGX_HTTP_OK
+ && (u->headers_in.content_length_n == -1
+ || (u->headers_in.content_length_n == tf->offset)))
+ {
ngx_http_upstream_store(r, u);
} else if ((p->upstream_error
|| (p->upstream_eof
&& u->headers_in.status_n != NGX_HTTP_OK))
- && u->pipe->temp_file->file.fd != NGX_INVALID_FILE)
+ && tf->file.fd != NGX_INVALID_FILE)
{
- if (ngx_delete_file(u->pipe->temp_file->file.name.data)
- == NGX_FILE_ERROR)
- {
+ if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) {
+
ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
ngx_delete_file_n " \"%s\" failed",
u->pipe->temp_file->file.name.data);
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
index 15987b1b1..f6184b6ff 100644
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -194,6 +194,8 @@ typedef struct {
ngx_table_elt_t *content_encoding;
#endif
+ off_t content_length_n;
+
ngx_array_t cache_control;
} ngx_http_upstream_headers_in_t;