[nginx] svn commit: r4299 - trunk/src/http
mdounin at mdounin.ru
mdounin at mdounin.ru
Fri Nov 18 15:09:09 UTC 2011
Author: mdounin
Date: 2011-11-18 15:09:08 +0000 (Fri, 18 Nov 2011)
New Revision: 4299
Log:
Upstream: don't cache unfinished responses.
Check if received data length match Content-Length header (if present),
don't cache response if no match found. This prevents caching of corrupted
response in case of premature connection close by upstream.
Modified:
trunk/src/http/ngx_http_upstream.c
Modified: trunk/src/http/ngx_http_upstream.c
===================================================================
--- trunk/src/http/ngx_http_upstream.c 2011-11-18 14:41:01 UTC (rev 4298)
+++ trunk/src/http/ngx_http_upstream.c 2011-11-18 15:09:08 UTC (rev 4299)
@@ -2696,10 +2696,18 @@
} else if (p->upstream_eof) {
- /* TODO: check length & update cache */
+ tf = u->pipe->temp_file;
- ngx_http_file_cache_update(r, u->pipe->temp_file);
+ if (u->headers_in.content_length_n == -1
+ || u->headers_in.content_length_n
+ == tf->offset - (off_t) r->cache->body_start)
+ {
+ ngx_http_file_cache_update(r, tf);
+ } else {
+ ngx_http_file_cache_free(r->cache, tf);
+ }
+
} else if (p->upstream_error) {
ngx_http_file_cache_free(r->cache, u->pipe->temp_file);
}
More information about the nginx-devel
mailing list