703789
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
703789
index 4ffb2cc8ad..76e6705889 100644
703789
--- a/src/http/ngx_http_special_response.c
703789
+++ b/src/http/ngx_http_special_response.c
703789
@@ -623,6 +623,12 @@ ngx_http_send_error_page(ngx_http_request_t *r, ngx_http_err_page_t *err_page)
703789
         return ngx_http_named_location(r, &uri);
703789
     }
703789
 
703789
+    r->expect_tested = 1;
703789
+
703789
+    if (ngx_http_discard_request_body(r) != NGX_OK) {
703789
+        r->keepalive = 0;
703789
+    }
703789
+
703789
     location = ngx_list_push(&r->headers_out.headers);
703789
 
703789
     if (location == NULL) {