diff --git a/libavformat/http.c b/libavformat/http.c
index 7a68378acb25f082849bd183da542dafeea3aef0..c15ca522c40807de4cb1b99e9e918b20eec15e5c 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -323,9 +323,11 @@ int ff_http_do_new_request(URLContext *h, const char *uri)
         return AVERROR(EINVAL);
     }
 
-    ret = http_shutdown(h, h->flags);
-    if (ret < 0)
-        return ret;
+    if (!s->end_chunked_post) {
+        ret = http_shutdown(h, h->flags);
+        if (ret < 0)
+            return ret;
+    }
 
     if (s->willclose)
         return AVERROR_EOF;