comparison src/http/ngx_http_core_module.c @ 7761:43a0a9e988be

Removed incorrect optimization of HEAD requests. The stub status module and ngx_http_send_response() (used by the empty gif module and the "return" directive) incorrectly assumed that responding to HEAD requests always results in r->header_only being set. This is not true, and results in incorrect behaviour, for example, in the following configuration: location / { image_filter size; return 200 test; } Fix is to remove this incorrect micro-optimization from both stub status module and ngx_http_send_response(). Reported by Chris Newton.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 19 Jan 2021 20:21:12 +0300
parents 681b78a98a52
children de0b6f1fe4e4
comparison
equal deleted inserted replaced
7760:83c4622053b0 7761:43a0a9e988be
1780 if (ngx_http_set_content_type(r) != NGX_OK) { 1780 if (ngx_http_set_content_type(r) != NGX_OK) {
1781 return NGX_HTTP_INTERNAL_SERVER_ERROR; 1781 return NGX_HTTP_INTERNAL_SERVER_ERROR;
1782 } 1782 }
1783 } 1783 }
1784 1784
1785 if (r->method == NGX_HTTP_HEAD || (r != r->main && val.len == 0)) { 1785 if (r != r->main && val.len == 0) {
1786 return ngx_http_send_header(r); 1786 return ngx_http_send_header(r);
1787 } 1787 }
1788 1788
1789 b = ngx_calloc_buf(r->pool); 1789 b = ngx_calloc_buf(r->pool);
1790 if (b == NULL) { 1790 if (b == NULL) {