]> git.kaiwu.me - nginx.git/commitdiff
Fix for incorrect 201 replies from dav module.
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 27 Sep 2011 11:09:55 +0000 (11:09 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 27 Sep 2011 11:09:55 +0000 (11:09 +0000)
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

src/http/ngx_http_special_response.c

index 0f08d987e5394eb59a81ccb4161da7185be28b6c..0d66a4b6b92b4581c3c60ce2d2879acda8ec419a 100644 (file)
@@ -421,7 +421,6 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
     if (error == NGX_HTTP_CREATED) {
         /* 201 */
         err = 0;
-        r->header_only = 1;
 
     } else if (error == NGX_HTTP_NO_CONTENT) {
         /* 204 */
@@ -636,7 +635,7 @@ ngx_http_send_special_response(ngx_http_request_t *r,
         r->headers_out.content_type_lowcase = NULL;
 
     } else {
-        r->headers_out.content_length_n = -1;
+        r->headers_out.content_length_n = 0;
     }
 
     if (r->headers_out.content_length) {
@@ -654,7 +653,7 @@ ngx_http_send_special_response(ngx_http_request_t *r,
     }
 
     if (ngx_http_error_pages[err].len == 0) {
-        return NGX_OK;
+        return ngx_http_send_special(r, NGX_HTTP_LAST);
     }
 
     b = ngx_calloc_buf(r->pool);