nginx-0.0.1-2003-05-14-21:13:13 import
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index 6213c4f..8c86b24 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -120,6 +120,7 @@
     r->headers_out.status = error;
 
     if (error < NGX_HTTP_BAD_REQUEST) {
+        /* 3XX */
         err = error - NGX_HTTP_MOVED_PERMANENTLY;
 
     } else {
@@ -133,9 +134,11 @@
         r->headers_out.content_type->value.data = "text/html";
 
         if (error < NGX_HTTP_INTERNAL_SERVER_ERROR) {
+            /* 4XX */
             err = error - NGX_HTTP_BAD_REQUEST + 3;
 
         } else {
+            /* 5XX */
             err = error - NGX_HTTP_INTERNAL_SERVER_ERROR + 3 + 17;
         }
     }
@@ -149,6 +152,15 @@
         }
     }
 
+    if (r->lingering_close == 1) {
+        switch (error) {
+            case NGX_HTTP_BAD_REQUEST:
+            case NGX_HTTP_REQUEST_URI_TOO_LARGE:
+            case NGX_HTTP_INTERNAL_SERVER_ERROR:
+                r->lingering_close = 0;
+        }
+    }
+
     if (error_pages[err].len == 0) {
         r->headers_out.content_length = -1;
     } else {