Ticket #7975: 0001-recognize-server-closing-http-connection.patch

File 0001-recognize-server-closing-http-connection.patch, 2.0 KB (added by ianklassen, 7 years ago)
  • libavformat/http.c

    From 174a8913afe4e335441e3a8a77c91e6a4b4b718c Mon Sep 17 00:00:00 2001
    From: ian <ian@virtualfunc.com>
    Date: Fri, 26 Jul 2019 15:03:31 -0500
    Subject: [PATCH] recognize server closing http connection
    
    ---
     libavformat/http.c | 19 +++++++++++++++----
     1 file changed, 15 insertions(+), 4 deletions(-)
    
    diff --git a/libavformat/http.c b/libavformat/http.c
    index 579debc..3bf2434 100644
    a b int ff_http_do_new_request(URLContext *h, const char *uri)  
    332332        return AVERROR(EINVAL);
    333333    }
    334334
     335    // read headers if not already loaded (this is needed to check if connection is closing)
     336    if (!s->end_header) {
     337      int new_location;
     338      http_read_header(h, &new_location);
     339
     340      if (s->willclose) {
     341        ret = ffurl_closep(&s->hd);
     342
     343        if (ret < 0)
     344          return ret;
     345      }
     346    }
     347
    335348    if (!s->end_chunked_post) {
    336349        ret = http_shutdown(h, h->flags);
    337350        if (ret < 0)
    338351            return ret;
    339352    }
    340353
    341     if (s->willclose)
    342         return AVERROR_EOF;
    343 
    344354    s->end_chunked_post = 0;
    345355    s->chunkend      = 0;
    346356    s->off           = 0;
    static int process_line(URLContext *h, char *line, int line_count,  
    9901000        } else if (!av_strcasecmp(tag, "Proxy-Authenticate")) {
    9911001            ff_http_auth_handle_header(&s->proxy_auth_state, tag, p);
    9921002        } else if (!av_strcasecmp(tag, "Connection")) {
    993             if (!strcmp(p, "close"))
     1003            if (strstr(p, "close") != NULL)
    9941004                s->willclose = 1;
    9951005        } else if (!av_strcasecmp(tag, "Server")) {
    9961006            if (!av_strcasecmp(p, "AkamaiGHost")) {
    static int http_shutdown(URLContext *h, int flags)  
    16371647            s->hd->flags |= AVIO_FLAG_NONBLOCK;
    16381648            read_ret = ffurl_read(s->hd, buf, sizeof(buf));
    16391649            s->hd->flags &= ~AVIO_FLAG_NONBLOCK;
     1650
    16401651            if (read_ret < 0 && read_ret != AVERROR(EAGAIN)) {
    16411652                av_log(h, AV_LOG_ERROR, "URL read error: %s\n", av_err2str(read_ret));
    16421653                ret = read_ret;