lavf/http: Correctly terminate session with HTTP POST client.
authorStephan Holljes <klaxa1337@googlemail.com>
Tue, 9 Jun 2015 20:26:48 +0000 (22:26 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 10 Jun 2015 16:17:28 +0000 (18:17 +0200)
Send a footer to correctly close client sockets.
This fixes network errors in client applications.

Signed-off-by: Stephan Holljes <klaxa1337@googlemail.com>
Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/http.c

index 2db2dea..676bfd5 100644 (file)
@@ -325,6 +325,7 @@ static int http_listen(URLContext *h, const char *uri, int flags,
     char lower_url[100];
     const char *lower_proto = "tcp";
     int port, new_location;
+    s->chunked_post = 1;
     av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port,
                  NULL, 0, uri);
     if (!strcmp(proto, "https"))
@@ -1242,7 +1243,8 @@ static int http_shutdown(URLContext *h, int flags)
     HTTPContext *s = h->priv_data;
 
     /* signal end of chunked encoding if used */
-    if ((flags & AVIO_FLAG_WRITE) && s->chunked_post) {
+    if (((flags & AVIO_FLAG_WRITE) && s->chunked_post) ||
+        ((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen)) {
         ret = ffurl_write(s->hd, footer, sizeof(footer) - 1);
         ret = ret > 0 ? 0 : ret;
         s->end_chunked_post = 1;