From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id EE0DD40A3C for ; Wed, 2 Feb 2022 23:50:04 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1F35168B11F; Thu, 3 Feb 2022 01:50:02 +0200 (EET) Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5309368AC7B for ; Thu, 3 Feb 2022 01:49:55 +0200 (EET) Received: by mail-ej1-f44.google.com with SMTP id a8so2299228ejc.8 for ; Wed, 02 Feb 2022 15:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=pJIGuv5yAK1mHj5cjr1VHs6ZkiIjBQzJm0qI1SWBpS0=; b=DmlS1Vs6JlI4OshrTne22ycBS8yZqxZoHaFb7SG66bjRA/NuvCZ8F8MwEMuWvu/Yx6 1Ys76ucrLjzk2D2KmmKWzh1sUg23dT24tb6jCNcuz4EQb74hgeqpVxfJmzNeTLJ5D2l5 VuT8Vim8uUph/Z9J8/VCv7o6MjgJnJ5c4GoP9axDRJ0PPugkUgGxe2jSpUcwx+ytfxcH 346fwknSOOgSKYKUNbEB3VtOfCB/+6LOkzMF4iEPeStZ2ttCG5cReDGXn6e7tR5ouX1W LFIsj8iC4w4zddGY91h4T5+hBGzKBr3QCU7u4E6uaF5uJXny79fkLvWzDYYDrCiYFjGA e58g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=pJIGuv5yAK1mHj5cjr1VHs6ZkiIjBQzJm0qI1SWBpS0=; b=LtApyb/mQ9peUllaNb+m3Q4oMj3n71gi9l8qonRlZ8UlMSl/V/5mCLPL89xwlnPZB9 cgyi9gno6zkJxuP/rUitcCVBHEmFZYori14drYeAzf44EJ8hRNhb9Hcd08Hvd/dwpEy3 0E7wvp2gK7fpp4qR/GM9kHGsKytiufRMFitCj1T9UASyKIelkoz8J3+X8X6Btd/UXNu6 uh5fO1sh3keQDNkVAZzgOxqOga+G5lXtKnXVcnxhQHpDHdz4nQ6RYwKAPx3PVL5lIcKv 5n/LR1e3CveqozNZ1m3SJYDEeKPpvhLY5rVJdcxF/pqv723hO7qQZr/JetXfU+D7OXn+ 45Rg== X-Gm-Message-State: AOAM531TXnLfCP6Ovaq/bK1jZhbv4yUr+adqED5Dp7fki0/0WYcPe1YZ zkAAPw4U4vMKuf9LpFtYAKtpK/cUr9Y= X-Google-Smtp-Source: ABdhPJwzec1e0uARUsT5jgRT2fZxZ1KttHLw3dXjBEK371hCL7akzam+F2gAAa7HrfSkuCF+j++aHA== X-Received: by 2002:a17:907:7da8:: with SMTP id oz40mr21408190ejc.328.1643845794673; Wed, 02 Feb 2022 15:49:54 -0800 (PST) Received: from vimacbookpro.vimeows.com (93-41-18-244.ip79.fastwebnet.it. [93.41.18.244]) by smtp.gmail.com with ESMTPSA id g7sm21613744edr.71.2022.02.02.15.49.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Feb 2022 15:49:54 -0800 (PST) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Thu, 3 Feb 2022 00:49:52 +0100 Message-Id: <20220202234953.6337-1-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] http: Improve handling of Content-Range with Transfer-Encoding:chunked X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Justin Ruggles When Transfer-Encoding:chunked is used, the client must ignore a Content-Length header, if present. However, it should not ignore a Content-Range header, which also includes the full size of the entity. --- libavformat/http.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 8f39d11a88..c89f8a5517 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -132,6 +132,7 @@ typedef struct HTTPContext { int64_t expires; char *new_location; AVDictionary *redirect_cache; + uint64_t filesize_from_content_range; } HTTPContext; #define OFFSET(x) offsetof(HTTPContext, x) @@ -839,7 +840,7 @@ static void parse_content_range(URLContext *h, const char *p) p += 6; s->off = strtoull(p, NULL, 10); if ((slash = strchr(p, '/')) && strlen(slash) > 0) - s->filesize = strtoull(slash + 1, NULL, 10); + s->filesize_from_content_range = strtoull(slash + 1, NULL, 10); } if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647)) h->is_streamed = 0; /* we _can_ in fact seek */ @@ -1341,6 +1342,7 @@ static int http_read_header(URLContext *h) av_freep(&s->new_location); s->expires = 0; s->chunksize = UINT64_MAX; + s->filesize_from_content_range = UINT64_MAX; for (;;) { if ((err = http_get_line(s, line, sizeof(line))) < 0) @@ -1356,6 +1358,10 @@ static int http_read_header(URLContext *h) s->line_count++; } + // filesize from Content-Range can always be used, even if using chunked Transfer-Encoding + if (s->filesize_from_content_range != UINT64_MAX) + s->filesize = s->filesize_from_content_range; + if (s->seekable == -1 && s->is_mediagateway && s->filesize == 2000000000) h->is_streamed = 1; /* we can in fact _not_ seek */ -- 2.34.1 _______________________________________________ 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".