Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 5299:b779728b180c
Upstream: fixed store/cache of unfinished responses.
In case of upstream eof, only responses with u->pipe->length == -1
are now cached/stored. This ensures that unfinished chunked responses
are not cached.
Note well - previously used checks for u->headers_in.content_length_n are
preserved. This provides an additional level of protection if protol data
disagree with Content-Length header provided (e.g., a FastCGI response
is sent with wrong Content-Length, or an incomple SCGI or uwsgi response),
as well as protects from storing of responses to HEAD requests. This should
be reconsidered if we'll consider caching of responses to HEAD requests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 25 Jul 2013 14:56:59 +0400 |
parents | a7b2db9119e0 |
children | f538a67c9f77 |
comparison
equal
deleted
inserted
replaced
5298:a7b2db9119e0 | 5299:b779728b180c |
---|---|
2983 if (p->upstream_eof || p->upstream_done) { | 2983 if (p->upstream_eof || p->upstream_done) { |
2984 | 2984 |
2985 tf = p->temp_file; | 2985 tf = p->temp_file; |
2986 | 2986 |
2987 if (u->headers_in.status_n == NGX_HTTP_OK | 2987 if (u->headers_in.status_n == NGX_HTTP_OK |
2988 && (p->upstream_done || p->length == -1) | |
2988 && (u->headers_in.content_length_n == -1 | 2989 && (u->headers_in.content_length_n == -1 |
2989 || u->headers_in.content_length_n == tf->offset)) | 2990 || u->headers_in.content_length_n == tf->offset)) |
2990 { | 2991 { |
2991 ngx_http_upstream_store(r, u); | 2992 ngx_http_upstream_store(r, u); |
2992 u->store = 0; | 2993 u->store = 0; |
3003 | 3004 |
3004 } else if (p->upstream_eof) { | 3005 } else if (p->upstream_eof) { |
3005 | 3006 |
3006 tf = p->temp_file; | 3007 tf = p->temp_file; |
3007 | 3008 |
3008 if (u->headers_in.content_length_n == -1 | 3009 if (p->length == -1 |
3009 || u->headers_in.content_length_n | 3010 && (u->headers_in.content_length_n == -1 |
3010 == tf->offset - (off_t) r->cache->body_start) | 3011 || u->headers_in.content_length_n |
3012 == tf->offset - (off_t) r->cache->body_start)) | |
3011 { | 3013 { |
3012 ngx_http_file_cache_update(r, tf); | 3014 ngx_http_file_cache_update(r, tf); |
3013 | 3015 |
3014 } else { | 3016 } else { |
3015 ngx_http_file_cache_free(r->cache, tf); | 3017 ngx_http_file_cache_free(r->cache, tf); |