};
+#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 }
};
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;
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;
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);
}
{ 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("") },
if (r->cache) {
r->http_version = NGX_HTTP_VERSION_9;
- u->headers_in.status_n = NGX_HTTP_OK;
return NGX_OK;
}
#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;
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;
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) {
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;
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;
n = 0;
for (p += 8; p < last; p++) {
- if (*p == ';' || *p == ' ') {
+ if (*p == ',' || *p == ';' || *p == ' ') {
break;
}
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;
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;
}