summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2010-02-01 15:46:14 +0000
committerIgor Sysoev <igor@sysoev.ru>2010-02-01 15:46:14 +0000
commit95a5ecb1ac78b14b759ada666b2114783fc1c2d2 (patch)
tree69fc825a431c976c901abe733501a8662e048845
parent848cc35a653e893add69b580c864d0cd8b419860 (diff)
downloadnginx-95a5ecb1ac78b14b759ada666b2114783fc1c2d2.tar.gz
nginx-95a5ecb1ac78b14b759ada666b2114783fc1c2d2.tar.bz2
merge r3137, r3198, r3199, r3353, r3370, r3371, r3398, r3399:
cache related fixes: *) do not pass buf with empty cached response, this fixes "zero size buf in output" alert *) hide cacheable Set-Cookie and P3P FastCGI response headers *) test comma separator in "Cache-Control" *) a cache manager thread handle was overwritten by a cache loader thread handle, this caused an exit delay, the bug had been introduced in r3248 *) fix handling cached HTTP/0.9 response *) log proxied HTTP/0.9 responses status as "009" *) fix the "If-None-Match" header name *) fix a cached zero-length body case
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c32
-rw-r--r--src/http/modules/ngx_http_log_module.c21
-rw-r--r--src/http/modules/ngx_http_proxy_module.c4
-rw-r--r--src/http/ngx_http_file_cache.c6
-rw-r--r--src/http/ngx_http_upstream.c7
-rw-r--r--src/os/win32/ngx_process_cycle.c4
6 files changed, 61 insertions, 13 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index bdc52b644..a4a62e4cc 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -523,6 +523,23 @@ static ngx_str_t ngx_http_fastcgi_hide_headers[] = {
};
+#if (NGX_HTTP_CACHE)
+
+static ngx_str_t ngx_http_fastcgi_hide_cache_headers[] = {
+ ngx_string("Status"),
+ ngx_string("X-Accel-Expires"),
+ ngx_string("X-Accel-Redirect"),
+ ngx_string("X-Accel-Limit-Rate"),
+ ngx_string("X-Accel-Buffering"),
+ ngx_string("X-Accel-Charset"),
+ ngx_string("Set-Cookie"),
+ ngx_string("P3P"),
+ ngx_null_string
+};
+
+#endif
+
+
static ngx_path_init_t ngx_http_fastcgi_temp_path = {
ngx_string(NGX_HTTP_FASTCGI_TEMP_PATH), { 1, 2, 0 }
};
@@ -1899,6 +1916,7 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
u_char *p;
size_t size;
uintptr_t *code;
+ ngx_str_t *h;
ngx_uint_t i;
ngx_keyval_t *src;
ngx_hash_init_t hash;
@@ -2119,10 +2137,18 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
hash.bucket_size = ngx_align(64, ngx_cacheline_size);
hash.name = "fastcgi_hide_headers_hash";
+#if (NGX_HTTP_CACHE)
+
+ h = conf->upstream.cache ? ngx_http_fastcgi_hide_cache_headers:
+ ngx_http_fastcgi_hide_headers;
+#else
+
+ h = ngx_http_fastcgi_hide_headers;
+
+#endif
+
if (ngx_http_upstream_hide_headers_hash(cf, &conf->upstream,
- &prev->upstream,
- ngx_http_fastcgi_hide_headers,
- &hash)
+ &prev->upstream, h, &hash)
!= NGX_OK)
{
return NGX_CONF_ERROR;
diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c
index e1d99c05a..515203889 100644
--- a/src/http/modules/ngx_http_log_module.c
+++ b/src/http/modules/ngx_http_log_module.c
@@ -542,8 +542,25 @@ ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf,
static u_char *
ngx_http_log_status(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
{
- return ngx_sprintf(buf, "%ui",
- r->err_status ? r->err_status : r->headers_out.status);
+ ngx_uint_t status;
+
+ if (r->err_status) {
+ status = r->err_status;
+
+ } else if (r->headers_out.status) {
+ status = r->headers_out.status;
+
+ } else if (r->http_version == NGX_HTTP_VERSION_9) {
+ *buf++ = '0';
+ *buf++ = '0';
+ *buf++ = '9';
+ return buf;
+
+ } else {
+ status = 0;
+ }
+
+ return ngx_sprintf(buf, "%ui", status);
}
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c
index 9da8b4c55..19dbd5cfc 100644
--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -530,7 +530,7 @@ static ngx_keyval_t ngx_http_proxy_cache_headers[] = {
{ ngx_string("Expect"), ngx_string("") },
{ ngx_string("If-Modified-Since"), ngx_string("") },
{ ngx_string("If-Unmodified-Since"), ngx_string("") },
- { ngx_string("If-Match-None"), ngx_string("") },
+ { ngx_string("If-None-Match"), ngx_string("") },
{ ngx_string("If-Match"), ngx_string("") },
{ ngx_string("Range"), ngx_string("") },
{ ngx_string("If-Range"), ngx_string("") },
@@ -1223,7 +1223,6 @@ ngx_http_proxy_process_status_line(ngx_http_request_t *r)
if (r->cache) {
r->http_version = NGX_HTTP_VERSION_9;
- u->headers_in.status_n = NGX_HTTP_OK;
return NGX_OK;
}
@@ -1239,7 +1238,6 @@ ngx_http_proxy_process_status_line(ngx_http_request_t *r)
#endif
r->http_version = NGX_HTTP_VERSION_9;
- u->headers_in.status_n = NGX_HTTP_OK;
u->state->status = NGX_HTTP_OK;
return NGX_OK;
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
index a60483d59..c02bc7740 100644
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -311,7 +311,7 @@ ngx_http_file_cache_open(ngx_http_request_t *r)
return n;
}
- if ((size_t) n <= c->header_start) {
+ if ((size_t) n < c->header_start) {
ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
"cache file \"%s\" is too small", c->file.name.data);
return NGX_ERROR;
@@ -718,6 +718,8 @@ ngx_http_cache_send(ngx_http_request_t *r)
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
+ r->header_only = (c->length - c->body_start) == 0;
+
rc = ngx_http_send_header(r);
if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
@@ -727,7 +729,7 @@ ngx_http_cache_send(ngx_http_request_t *r)
b->file_pos = c->body_start;
b->file_last = c->length;
- b->in_file = (c->length - c->body_start) ? 1: 0;
+ b->in_file = 1;
b->last_buf = (r == r->main) ? 1: 0;
b->last_in_chain = 1;
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 943ef69e8..2deec4819 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -712,6 +712,11 @@ ngx_http_upstream_cache_send(ngx_http_request_t *r, ngx_http_upstream_t *u)
r->cached = 1;
c = r->cache;
+ if (c->header_start == c->body_start) {
+ r->http_version = NGX_HTTP_VERSION_9;
+ return ngx_http_cache_send(r);
+ }
+
/* TODO: cache stack */
u->buffer = *c->buf;
@@ -3017,7 +3022,7 @@ ngx_http_upstream_process_cache_control(ngx_http_request_t *r,
n = 0;
for (p += 8; p < last; p++) {
- if (*p == ';' || *p == ' ') {
+ if (*p == ',' || *p == ';' || *p == ' ') {
break;
}
diff --git a/src/os/win32/ngx_process_cycle.c b/src/os/win32/ngx_process_cycle.c
index 59016b961..e3b513a1c 100644
--- a/src/os/win32/ngx_process_cycle.c
+++ b/src/os/win32/ngx_process_cycle.c
@@ -599,7 +599,7 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, char *mevn)
HANDLE mev, events[3];
u_long nev, ev;
ngx_err_t err;
- ngx_tid_t wtid, cmtid;
+ ngx_tid_t wtid, cmtid, cltid;
ngx_log_t *log;
log = cycle->log;
@@ -671,7 +671,7 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, char *mevn)
goto failed;
}
- if (ngx_create_thread(&cmtid, ngx_cache_loader_thread, NULL, log) != 0) {
+ if (ngx_create_thread(&cltid, ngx_cache_loader_thread, NULL, log) != 0) {
goto failed;
}