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

Submitted by Ian Klassen on Aug. 15, 2019, 10:14 p.m.

Details

Message ID CAFdYB-gsLrKQ9c9TFO_2jWEg6ofhyXiAR1hT5eaBmJoAVph8ig@mail.gmail.com
State New
Headers show

Commit Message

Ian Klassen Aug. 15, 2019, 10:14 p.m.
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(-)

     s->off           = 0;

Comments

Michael Niedermayer Aug. 16, 2019, 9:35 a.m.
On Thu, Aug 15, 2019 at 05:14:38PM -0500, Ian Klassen wrote:
> 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)

this patch looks corrupted by line breaks

[...]
Ian Klassen Aug. 16, 2019, 12:33 p.m.
Pasting it into an email may not have been a good idea... here it is as an
attachment. Thanks.


On Fri, Aug 16, 2019 at 4:35 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> On Thu, Aug 15, 2019 at 05:14:38PM -0500, Ian Klassen wrote:
> > 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)
>
> this patch looks corrupted by line breaks
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker.
> User
> questions about the command line tools should be sent to the ffmpeg-user
> ML.
> And questions about how to use libav* should be sent to the libav-user ML.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Patch hide | download patch | download mbox

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;