From patchwork Thu Aug 15 22:14:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Klassen X-Patchwork-Id: 14536 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 35C6E447CFE for ; Fri, 16 Aug 2019 01:20:11 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0BD4268AC64; Fri, 16 Aug 2019 01:20:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D12ED68AC39 for ; Fri, 16 Aug 2019 01:20:04 +0300 (EEST) Received: by mail-qt1-f179.google.com with SMTP id v38so4103398qtb.0 for ; Thu, 15 Aug 2019 15:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtualfunc.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=CsnNlKKSb2ic9EYTY23gvTW9gpssNWLqqTChyd7CTGo=; b=KDfOv0fpPsR4MEkFxAUfXiSDfwgLeF6Bd5l0A2afwbR4R8S4pEBTYXCFW2ZptTq3Xd tAiuo6CDZmbJt1l4oQy/rZww4uKWJ52S3TypnbjlBMQ7SAxzvkf7uxsd+SMcWieSJWEb lWvCJnrcVoDigxT+8QZDQKxUabxYkVM6eH8Dz3MCXyvuCV0HozF5DWEgsHty9Hvd1zab jsNYlfSQjUc31/3nxHvRf48c75OIeOjpkhblAohYdzTnFL+iFBDKVN7982V4ylLIVkXK ohER47haAo91QnmwAvwsBpPSdj6l7c5ve62Xt8jReaw9lQalir/az8Qiefg903cgVnZY ifNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=CsnNlKKSb2ic9EYTY23gvTW9gpssNWLqqTChyd7CTGo=; b=mdV8sAzXYqR9kvksJ2ZyUmdUcWHuvdyU/xgI6D8TvK4yANiddi3GMw5/IfRdoVhRQD MBBJ/EDfvHTDzwwVJCy1kXb7HC7beWcSpNrwWxg9+6hruVVIPDmX960s6yMZFwLp8RId +jx0nblW2E1TLT96hCjF7QCeBr58HrBl+CTcj04sf9psDGjPwQs+KGeJL6lfN1ICP+Qp bd0B1tWn8ml79p7IO9xY+SVxHoXeB8gT2msNqa36xJKx0ok8Sl+WRs9/T833Ctg+arbe a0meTxs/JaQ73huuhgBDgO77wZ/fNCXegovgJKlGamkDTENhOtQa/Sx4JDp7f+cHr/u3 FdIg== X-Gm-Message-State: APjAAAWwtJw7Q4Y/APo41oNtVGvl2ALHym/4dZW48TazKp7PVGawMhi+ 91/zO2bMkhac0/gksw/OR+/+tgaAhUab5weHOWV/PQz+qK8= X-Google-Smtp-Source: APXvYqyC9NaE19iJdOU07WnoZKv4nBZaXEsTucdTs7i+y1J/7lcQHUMyVHtuEHoATZ7RFhIobBOSoGZ6blIWyQzNSSc= X-Received: by 2002:ac8:5514:: with SMTP id j20mr6041326qtq.230.1565907288952; Thu, 15 Aug 2019 15:14:48 -0700 (PDT) MIME-Version: 1.0 From: Ian Klassen Date: Thu, 15 Aug 2019 17:14:38 -0500 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [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. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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; 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;