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 DFE2D40A55 for ; Thu, 3 Feb 2022 01:27:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DBCF868B179; Thu, 3 Feb 2022 03:27:11 +0200 (EET) Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D654E68AF07 for ; Thu, 3 Feb 2022 03:27:05 +0200 (EET) Received: by mail-ua1-f52.google.com with SMTP id 60so2565992uae.1 for ; Wed, 02 Feb 2022 17:27:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=4ewvuhHaNQeuhIR/Nz0gwuwpibNHYqzy4f+H/RJ+bnI=; b=ihYZPVQfC9EHZzquZFibQO0OpJrtn/BEEZCBCwFjyGUT/5MvHaKmGjRdnT0KDaB4OV 1+nrkTfAFyp4gB7qvZi0n2bn3TVSDDpRGO476Hw4ELpwGa8+JPCzd4RbyAs5TtwpFBfu Kd1UKYDNDkCWhenJ/G/Prw6UotEJ2oliNUcBK/Xjj+UY/iXLIq8tg5Ppozq9jQMUtipN MpfqaqVBI6X29s1nvInY6cj/jVpW5UPWS2Jnxn5vBhb2GSUGoB82Qs0Yo5ZtR/jyWGMo j42RHvG9blc1vdOcS+Jqh9GDh/D8DDew1ltpQirmbI3NThVkoXnU9B2/b2N8tdClMKFK ujjA== X-Gm-Message-State: AOAM532pWgTXzYL36L9DfLZcYNxZgXfwZIY6ie3m2W7VZqwWymnqo5FN imRI3I+3/wJAR7WrV7UXAT2TUPLU77Ve13GO7MVpMqDw7b0= X-Google-Smtp-Source: ABdhPJywzS9dev1fFP61um5tUy3f4iKjGAXQn3sC4+BdaNZgy8nBH3EXgLHPe2p2iC3OODfpz6rlrLY50kGa58uecMY= X-Received: by 2002:ab0:1511:: with SMTP id o17mr13482189uae.79.1643851623994; Wed, 02 Feb 2022 17:27:03 -0800 (PST) MIME-Version: 1.0 References: <20220202234953.6337-1-vittorio.giovara@gmail.com> In-Reply-To: <20220202234953.6337-1-vittorio.giovara@gmail.com> From: Aman Karmani Date: Wed, 2 Feb 2022 17:26:52 -0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [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: On Wed, Feb 2, 2022 at 3:50 PM Vittorio Giovara wrote: > 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); > The size part of the range header is optional, and can be '*' as well. See also https://patchwork.ffmpeg.org/project/ffmpeg/patch/20211005233244.37582-1-ffmpeg@tmm1.net/ > } > 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". > _______________________________________________ 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".