summaryrefslogtreecommitdiff
path: root/src/http/ngx_http_upstream.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-04-20 06:16:24 +0000
committerJonathan Kolb <jon@b0g.us>2009-04-20 06:16:24 +0000
commite7d62b21eb69be11894969ba66d3590f4cbd5b9d (patch)
tree4eb771dd2000343925a35b4742af684f6603d0c8 /src/http/ngx_http_upstream.c
parentb0e75119a75c319f70cc0ddd980fa92a8a716580 (diff)
downloadnginx-e7d62b21eb69be11894969ba66d3590f4cbd5b9d.tar.gz
Changes with nginx 0.7.52 20 Apr 2009v0.7.52
*) Feature: the first native Windows binary release. *) Bugfix: in processing HEAD method while caching. *) Bugfix: in processing the "If-Modified-Since", "If-Range", etc. client request header lines while caching. *) Bugfix: now the "Set-Cookie" and "P3P" header lines are hidden in cacheable responses. *) Bugfix: if nginx was built with the ngx_http_perl_module and with a perl which supports threads, then during a master process exit the message "panic: MUTEX_LOCK" might be issued. *) Bugfix: nginx could not be built --without-http-cache; the bug had appeared in 0.7.48. *) Bugfix: nginx could not be built on platforms different from i386, amd64, sparc, and ppc; the bug had appeared in 0.7.42.
Diffstat (limited to 'src/http/ngx_http_upstream.c')
-rw-r--r--src/http/ngx_http_upstream.c60
1 files changed, 49 insertions, 11 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 82f110246..369c7bb28 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -532,10 +532,14 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
ngx_int_t rc;
ngx_http_cache_t *c;
- if (!(r->method & NGX_HTTP_GET)) {
+ if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
return NGX_DECLINED;
}
+ if (r->method & NGX_HTTP_HEAD) {
+ u->method = ngx_http_core_get_method;
+ }
+
c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t));
if (c == NULL) {
return NGX_ERROR;
@@ -1821,11 +1825,32 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
rc = ngx_http_send_header(r);
- if (rc == NGX_ERROR || rc > NGX_OK || r->post_action || r->header_only) {
+ if (rc == NGX_ERROR || rc > NGX_OK || r->post_action) {
ngx_http_upstream_finalize_request(r, u, rc);
return;
}
+ c = r->connection;
+
+ if (r->header_only) {
+
+ if (u->cacheable || u->store) {
+
+ if (ngx_shutdown_socket(c->fd, NGX_WRITE_SHUTDOWN) == -1) {
+ ngx_connection_error(c, ngx_socket_errno,
+ ngx_shutdown_socket_n " failed");
+ }
+
+ r->read_event_handler = ngx_http_request_empty_handler;
+ r->write_event_handler = ngx_http_request_empty_handler;
+ c->error = 1;
+
+ } else {
+ ngx_http_upstream_finalize_request(r, u, rc);
+ return;
+ }
+ }
+
u->header_sent = 1;
if (r->request_body && r->request_body->temp_file) {
@@ -1833,8 +1858,6 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
r->request_body->temp_file->file.fd = NGX_INVALID_FILE;
}
- c = r->connection;
-
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
if (!u->buffering) {
@@ -1942,6 +1965,7 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
} else {
u->cacheable = 0;
+ r->headers_out.last_modified_time = -1;
}
}
@@ -2819,8 +2843,6 @@ static ngx_int_t
ngx_http_upstream_process_cache_control(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset)
{
- u_char *p, *last;
- ngx_int_t n;
ngx_array_t *pa;
ngx_table_elt_t **ph;
@@ -2840,6 +2862,11 @@ ngx_http_upstream_process_cache_control(ngx_http_request_t *r,
*ph = h;
+#if (NGX_HTTP_CACHE)
+ {
+ u_char *p, *last;
+ ngx_int_t n;
+
if (r->cache == NULL) {
return NGX_OK;
}
@@ -2885,6 +2912,9 @@ ngx_http_upstream_process_cache_control(ngx_http_request_t *r,
}
r->cache->valid_sec = ngx_time() + n;
+ }
+#endif
+
return NGX_OK;
}
@@ -2893,10 +2923,12 @@ static ngx_int_t
ngx_http_upstream_process_expires(ngx_http_request_t *r, ngx_table_elt_t *h,
ngx_uint_t offset)
{
- time_t expires;
-
r->upstream->headers_in.expires = h;
+#if (NGX_HTTP_CACHE)
+ {
+ time_t expires;
+
if (r->cache == NULL) {
return NGX_OK;
}
@@ -2913,6 +2945,8 @@ ngx_http_upstream_process_expires(ngx_http_request_t *r, ngx_table_elt_t *h,
}
r->cache->valid_sec = expires;
+ }
+#endif
return NGX_OK;
}
@@ -2922,12 +2956,14 @@ static ngx_int_t
ngx_http_upstream_process_accel_expires(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset)
{
+ r->upstream->headers_in.x_accel_expires = h;
+
+#if (NGX_HTTP_CACHE)
+ {
u_char *p;
size_t len;
ngx_int_t n;
- r->upstream->headers_in.x_accel_expires = h;
-
if (r->cache == NULL) {
return NGX_OK;
}
@@ -2958,6 +2994,8 @@ ngx_http_upstream_process_accel_expires(ngx_http_request_t *r,
if (n != NGX_ERROR) {
r->cache->valid_sec = n;
}
+ }
+#endif
return NGX_OK;
}
@@ -3163,7 +3201,7 @@ ngx_http_upstream_copy_last_modified(ngx_http_request_t *r, ngx_table_elt_t *h,
#if (NGX_HTTP_CACHE)
- if (r->cached) {
+ if (r->cached || r->upstream->cacheable) {
r->headers_out.last_modified = ho;
r->headers_out.last_modified_time = ngx_http_parse_time(h->value.data,
h->value.len);