]> git.kaiwu.me - nginx.git/commitdiff
set "Content-Length: 0" for errors handled by "return 204"
authorIgor Sysoev <igor@sysoev.ru>
Mon, 2 Oct 2006 10:22:51 +0000 (10:22 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 2 Oct 2006 10:22:51 +0000 (10:22 +0000)
src/http/ngx_http_request.h
src/http/ngx_http_script.c
src/http/ngx_http_special_response.c

index b9ad2b54d2023d8b349d836e5486ebe6679a4ee7..08ccd1348176953d5dc99a045c7271c64462a0ae 100644 (file)
@@ -430,6 +430,7 @@ struct ngx_http_request_s {
     unsigned                          plain_http:1;
     unsigned                          chunked:1;
     unsigned                          header_only:1;
+    unsigned                          zero_body:1;
     unsigned                          keepalive:1;
     unsigned                          lingering_close:1;
     unsigned                          discard_body:1;
index 3a9e2a85bc703e8d00d06eea314ea6f14bb8e415..e8bce19117bc3e91358acf39adaef7a901480b78 100644 (file)
@@ -841,6 +841,7 @@ ngx_http_script_return_code(ngx_http_script_engine_t *e)
 
     if (code->status == NGX_HTTP_NO_CONTENT) {
         e->request->header_only = 1;
+        e->request->zero_body = 1;
     }
 
     e->ip += sizeof(ngx_http_script_return_code_t) - sizeof(uintptr_t);
index d249c272e03f9e8a1681772f2efbdc6bda36bb64..c8190ed18972bce101577f1a203fea15613d1e8b 100644 (file)
@@ -455,25 +455,32 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
 
     msie_padding = 0;
 
-    if (error_pages[err].len) {
-        r->headers_out.content_length_n = error_pages[err].len
-                                          + sizeof(error_tail) - 1;
-
-        if (clcf->msie_padding
-            && r->headers_in.msie
-            && r->http_version >= NGX_HTTP_VERSION_10
-            && error >= NGX_HTTP_BAD_REQUEST
-            && error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
-        {
-            r->headers_out.content_length_n += sizeof(ngx_http_msie_stub) - 1;
-            msie_padding = 1;
-        }
+    if (!r->zero_body) {
+        if (error_pages[err].len) {
+            r->headers_out.content_length_n = error_pages[err].len
+                                              + sizeof(error_tail) - 1;
+
+            if (clcf->msie_padding
+                && r->headers_in.msie
+                && r->http_version >= NGX_HTTP_VERSION_10
+                && error >= NGX_HTTP_BAD_REQUEST
+                && error != NGX_HTTP_REQUEST_URI_TOO_LARGE)
+            {
+                r->headers_out.content_length_n +=
+                                                sizeof(ngx_http_msie_stub) - 1;
+                msie_padding = 1;
+            }
 
-        r->headers_out.content_type.len = sizeof("text/html") - 1;
-        r->headers_out.content_type.data = (u_char *) "text/html";
+            r->headers_out.content_type.len = sizeof("text/html") - 1;
+            r->headers_out.content_type.data = (u_char *) "text/html";
+
+        } else {
+            r->headers_out.content_length_n = -1;
+        }
 
     } else {
-        r->headers_out.content_length_n = -1;
+        r->headers_out.content_length_n = 0;
+        err = 0;
     }
 
     if (r->headers_out.content_length) {