aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2009-04-15 09:53:22 +0000
committerIgor Sysoev <igor@sysoev.ru>2009-04-15 09:53:22 +0000
commitea8536b8219385eff9ecea62cbad6ad31e4db616 (patch)
tree4f6d8856217b9211a57df195729e4eda40bf2e05 /src
parent1f450f5b1fd427bcea6756e2bb1a15e623f6b500 (diff)
downloadnginx-ea8536b8219385eff9ecea62cbad6ad31e4db616.tar.gz
nginx-ea8536b8219385eff9ecea62cbad6ad31e4db616.zip
support HEAD in proxy cache
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_core_module.c2
-rw-r--r--src/http/ngx_http_core_module.h2
-rw-r--r--src/http/ngx_http_upstream.c20
3 files changed, 21 insertions, 3 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index ca1fbead0..26f24b360 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -691,7 +691,7 @@ ngx_module_t ngx_http_core_module = {
};
-static ngx_str_t ngx_http_core_get_method = { 3, (u_char *) "GET " };
+ngx_str_t ngx_http_core_get_method = { 3, (u_char *) "GET " };
void
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 8b1db54a2..546ebbb56 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -468,6 +468,8 @@ extern ngx_module_t ngx_http_core_module;
extern ngx_uint_t ngx_http_max_module;
+extern ngx_str_t ngx_http_core_get_method;
+
#define ngx_http_clear_content_length(r) \
\
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 82f110246..e7e809103 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,23 @@ 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;
}
+ if (r->header_only) {
+ if (u->cacheable || u->store) {
+ r->read_event_handler = ngx_http_request_empty_handler;
+ r->write_event_handler = ngx_http_request_empty_handler;
+ r->connection->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) {