mirror of
https://github.com/nginx/nginx.git
synced 2025-06-12 21:52:41 +08:00
support HEAD in proxy cache
This commit is contained in:
parent
1f450f5b1f
commit
ea8536b821
@ -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
|
void
|
||||||
|
@ -468,6 +468,8 @@ extern ngx_module_t ngx_http_core_module;
|
|||||||
|
|
||||||
extern ngx_uint_t ngx_http_max_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) \
|
#define ngx_http_clear_content_length(r) \
|
||||||
\
|
\
|
||||||
|
@ -532,10 +532,14 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
ngx_int_t rc;
|
ngx_int_t rc;
|
||||||
ngx_http_cache_t *c;
|
ngx_http_cache_t *c;
|
||||||
|
|
||||||
if (!(r->method & NGX_HTTP_GET)) {
|
if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
|
||||||
return NGX_DECLINED;
|
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));
|
c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t));
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
return NGX_ERROR;
|
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);
|
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);
|
ngx_http_upstream_finalize_request(r, u, rc);
|
||||||
return;
|
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;
|
u->header_sent = 1;
|
||||||
|
|
||||||
if (r->request_body && r->request_body->temp_file) {
|
if (r->request_body && r->request_body->temp_file) {
|
||||||
|
Loading…
Reference in New Issue
Block a user