[FFmpeg-devel] [PATCH v2] avformat/http: Fixes #7975. Before reusing the connection the headers are checked to see if the server is closing the connection.

Ian Klassen ian at virtualfunc.com
Fri Aug 16 01:14:38 EEST 2019


Hi,

Sorry Moritz, I somehow missed your feedback. Here's an updated patch with
the fixed formatting. I also set up a server that you can test with. Try:

ffmpeg -i test.mp4 -hls_flags +append_list -hls_time 6 -method PUT
-http_persistent 1 http://45.33.124.115/stream.m3u8

The server has persistent connections turned off so you'll see the errors
appear but they should be resolved once you apply the patch.

Thanks.

Ian

---
 libavformat/http.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 579debc..dcbd33a 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -332,15 +332,22 @@ int ff_http_do_new_request(URLContext *h, const char
*uri)
         return AVERROR(EINVAL);
     }

+    if (!s->end_header) {
+        int new_location;
+        http_read_header(h, &new_location);
+        if (s->willclose) {
+            ret = ffurl_closep(&s->hd);
+            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;
-
     s->end_chunked_post = 0;
     s->chunkend      = 0;
     s->off           = 0;
-- 
2.7.4


More information about the ffmpeg-devel mailing list