set "Content-Length: 0" for errors handled by "return 204"
This commit is contained in:
parent
537a359d58
commit
85e48a977d
3 changed files with 24 additions and 15 deletions
|
@ -430,6 +430,7 @@ struct ngx_http_request_s {
|
||||||
unsigned plain_http:1;
|
unsigned plain_http:1;
|
||||||
unsigned chunked:1;
|
unsigned chunked:1;
|
||||||
unsigned header_only:1;
|
unsigned header_only:1;
|
||||||
|
unsigned zero_body:1;
|
||||||
unsigned keepalive:1;
|
unsigned keepalive:1;
|
||||||
unsigned lingering_close:1;
|
unsigned lingering_close:1;
|
||||||
unsigned discard_body:1;
|
unsigned discard_body:1;
|
||||||
|
|
|
@ -841,6 +841,7 @@ ngx_http_script_return_code(ngx_http_script_engine_t *e)
|
||||||
|
|
||||||
if (code->status == NGX_HTTP_NO_CONTENT) {
|
if (code->status == NGX_HTTP_NO_CONTENT) {
|
||||||
e->request->header_only = 1;
|
e->request->header_only = 1;
|
||||||
|
e->request->zero_body = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
e->ip += sizeof(ngx_http_script_return_code_t) - sizeof(uintptr_t);
|
e->ip += sizeof(ngx_http_script_return_code_t) - sizeof(uintptr_t);
|
||||||
|
|
|
@ -455,6 +455,7 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
||||||
|
|
||||||
msie_padding = 0;
|
msie_padding = 0;
|
||||||
|
|
||||||
|
if (!r->zero_body) {
|
||||||
if (error_pages[err].len) {
|
if (error_pages[err].len) {
|
||||||
r->headers_out.content_length_n = error_pages[err].len
|
r->headers_out.content_length_n = error_pages[err].len
|
||||||
+ sizeof(error_tail) - 1;
|
+ sizeof(error_tail) - 1;
|
||||||
|
@ -465,7 +466,8 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
||||||
&& error >= NGX_HTTP_BAD_REQUEST
|
&& error >= NGX_HTTP_BAD_REQUEST
|
||||||
&& error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
|
&& error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
|
||||||
{
|
{
|
||||||
r->headers_out.content_length_n += sizeof(ngx_http_msie_stub) - 1;
|
r->headers_out.content_length_n +=
|
||||||
|
sizeof(ngx_http_msie_stub) - 1;
|
||||||
msie_padding = 1;
|
msie_padding = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,6 +478,11 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
|
||||||
r->headers_out.content_length_n = -1;
|
r->headers_out.content_length_n = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
r->headers_out.content_length_n = 0;
|
||||||
|
err = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (r->headers_out.content_length) {
|
if (r->headers_out.content_length) {
|
||||||
r->headers_out.content_length->hash = 0;
|
r->headers_out.content_length->hash = 0;
|
||||||
r->headers_out.content_length = NULL;
|
r->headers_out.content_length = NULL;
|
||||||
|
|
Loading…
Reference in a new issue