comparison src/http/ngx_http_upstream.c @ 2701:756f73ca1e39

support HEAD in proxy cache
author Igor Sysoev <igor@sysoev.ru>
date Wed, 15 Apr 2009 09:53:22 +0000
parents 111e6e62af32
children 3b6afa999c2f
comparison
equal deleted inserted replaced
2700:aee784753144 2701:756f73ca1e39
530 ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u) 530 ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
531 { 531 {
532 ngx_int_t rc; 532 ngx_int_t rc;
533 ngx_http_cache_t *c; 533 ngx_http_cache_t *c;
534 534
535 if (!(r->method & NGX_HTTP_GET)) { 535 if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
536 return NGX_DECLINED; 536 return NGX_DECLINED;
537 }
538
539 if (r->method & NGX_HTTP_HEAD) {
540 u->method = ngx_http_core_get_method;
537 } 541 }
538 542
539 c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t)); 543 c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t));
540 if (c == NULL) { 544 if (c == NULL) {
541 return NGX_ERROR; 545 return NGX_ERROR;
1819 ngx_connection_t *c; 1823 ngx_connection_t *c;
1820 ngx_http_core_loc_conf_t *clcf; 1824 ngx_http_core_loc_conf_t *clcf;
1821 1825
1822 rc = ngx_http_send_header(r); 1826 rc = ngx_http_send_header(r);
1823 1827
1824 if (rc == NGX_ERROR || rc > NGX_OK || r->post_action || r->header_only) { 1828 if (rc == NGX_ERROR || rc > NGX_OK || r->post_action) {
1825 ngx_http_upstream_finalize_request(r, u, rc); 1829 ngx_http_upstream_finalize_request(r, u, rc);
1826 return; 1830 return;
1831 }
1832
1833 if (r->header_only) {
1834 if (u->cacheable || u->store) {
1835 r->read_event_handler = ngx_http_request_empty_handler;
1836 r->write_event_handler = ngx_http_request_empty_handler;
1837 r->connection->error = 1;
1838
1839 } else {
1840 ngx_http_upstream_finalize_request(r, u, rc);
1841 return;
1842 }
1827 } 1843 }
1828 1844
1829 u->header_sent = 1; 1845 u->header_sent = 1;
1830 1846
1831 if (r->request_body && r->request_body->temp_file) { 1847 if (r->request_body && r->request_body->temp_file) {