Mercurial > hg > nginx
comparison src/http/modules/ngx_http_stub_status_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 | 2a288909abc6 |
children |
comparison
equal
deleted
inserted
replaced
7760:83c4622053b0 | 7761:43a0a9e988be |
---|---|
101 | 101 |
102 r->headers_out.content_type_len = sizeof("text/plain") - 1; | 102 r->headers_out.content_type_len = sizeof("text/plain") - 1; |
103 ngx_str_set(&r->headers_out.content_type, "text/plain"); | 103 ngx_str_set(&r->headers_out.content_type, "text/plain"); |
104 r->headers_out.content_type_lowcase = NULL; | 104 r->headers_out.content_type_lowcase = NULL; |
105 | 105 |
106 if (r->method == NGX_HTTP_HEAD) { | |
107 r->headers_out.status = NGX_HTTP_OK; | |
108 | |
109 rc = ngx_http_send_header(r); | |
110 | |
111 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) { | |
112 return rc; | |
113 } | |
114 } | |
115 | |
116 size = sizeof("Active connections: \n") + NGX_ATOMIC_T_LEN | 106 size = sizeof("Active connections: \n") + NGX_ATOMIC_T_LEN |
117 + sizeof("server accepts handled requests\n") - 1 | 107 + sizeof("server accepts handled requests\n") - 1 |
118 + 6 + 3 * NGX_ATOMIC_T_LEN | 108 + 6 + 3 * NGX_ATOMIC_T_LEN |
119 + sizeof("Reading: Writing: Waiting: \n") + 3 * NGX_ATOMIC_T_LEN; | 109 + sizeof("Reading: Writing: Waiting: \n") + 3 * NGX_ATOMIC_T_LEN; |
120 | 110 |