Welcome! Log In Create A New Profile

Advanced

[nginx] Upstream: fixed store/cache of unfinished responses.

Maxim Dounin
July 25, 2013 08:00AM
details: http://hg.nginx.org/nginx/rev/b779728b180c
branches:
changeset: 5299:b779728b180c
user: Maxim Dounin <mdounin@mdounin.ru>
date: Thu Jul 25 14:56:59 2013 +0400
description:
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.

diffstat:

src/http/ngx_http_upstream.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)

diffs (25 lines):

diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2985,6 +2985,7 @@ ngx_http_upstream_process_request(ngx_ht
tf = p->temp_file;

if (u->headers_in.status_n == NGX_HTTP_OK
+ && (p->upstream_done || p->length == -1)
&& (u->headers_in.content_length_n == -1
|| u->headers_in.content_length_n == tf->offset))
{
@@ -3005,9 +3006,10 @@ ngx_http_upstream_process_request(ngx_ht

tf = p->temp_file;

- if (u->headers_in.content_length_n == -1
- || u->headers_in.content_length_n
- == tf->offset - (off_t) r->cache->body_start)
+ if (p->length == -1
+ && (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);


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Upstream: fixed store/cache of unfinished responses.

Maxim Dounin 655 July 25, 2013 08:00AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 303
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready