comparison src/http/ngx_http_special_response.c @ 4146:55acacac22df

Fix for incorrect 201 replies from dav module. Replies with 201 code contain body, and we should clearly indicate it's empty if it's empty. Before 0.8.32 chunked was explicitly disabled for 201 replies and as a result empty body was indicated by connection close (not perfect, but worked). Since 0.8.32 chunked is enabled, and this causes incorrect responses from dav module when HTTP/1.1 is used: with "Transfer-Encoding: chunked" but no chunks at all. Fix is to actually return empty body in special response handler instead of abusing r->header_only flag. See here for initial report: http://mailman.nginx.org/pipermail/nginx-ru/2010-October/037535.html
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 27 Sep 2011 11:09:55 +0000
parents 39ad979cd31e
children 1d52dd2b5bb7
comparison
equal deleted inserted replaced
4145:f321e9750c8c 4146:55acacac22df
419 } 419 }
420 420
421 if (error == NGX_HTTP_CREATED) { 421 if (error == NGX_HTTP_CREATED) {
422 /* 201 */ 422 /* 201 */
423 err = 0; 423 err = 0;
424 r->header_only = 1;
425 424
426 } else if (error == NGX_HTTP_NO_CONTENT) { 425 } else if (error == NGX_HTTP_NO_CONTENT) {
427 /* 204 */ 426 /* 204 */
428 err = 0; 427 err = 0;
429 428
634 r->headers_out.content_type_len = sizeof("text/html") - 1; 633 r->headers_out.content_type_len = sizeof("text/html") - 1;
635 ngx_str_set(&r->headers_out.content_type, "text/html"); 634 ngx_str_set(&r->headers_out.content_type, "text/html");
636 r->headers_out.content_type_lowcase = NULL; 635 r->headers_out.content_type_lowcase = NULL;
637 636
638 } else { 637 } else {
639 r->headers_out.content_length_n = -1; 638 r->headers_out.content_length_n = 0;
640 } 639 }
641 640
642 if (r->headers_out.content_length) { 641 if (r->headers_out.content_length) {
643 r->headers_out.content_length->hash = 0; 642 r->headers_out.content_length->hash = 0;
644 r->headers_out.content_length = NULL; 643 r->headers_out.content_length = NULL;
652 if (rc == NGX_ERROR || r->header_only) { 651 if (rc == NGX_ERROR || r->header_only) {
653 return rc; 652 return rc;
654 } 653 }
655 654
656 if (ngx_http_error_pages[err].len == 0) { 655 if (ngx_http_error_pages[err].len == 0) {
657 return NGX_OK; 656 return ngx_http_send_special(r, NGX_HTTP_LAST);
658 } 657 }
659 658
660 b = ngx_calloc_buf(r->pool); 659 b = ngx_calloc_buf(r->pool);
661 if (b == NULL) { 660 if (b == NULL) {
662 return NGX_ERROR; 661 return NGX_ERROR;