diff mbox series

[FFmpeg-devel,2/2] http: Send a Range header even when the offset is 0

Message ID 20220202234953.6337-2-vittorio.giovara@gmail.com
State Accepted
Commit 0dd1ff67c8a5b687f4b9beb51b425ef7fb8b72c1
Headers show
Series [FFmpeg-devel,1/2] http: Improve handling of Content-Range with Transfer-Encoding:chunked | expand


Context Check Description
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Vittorio Giovara Feb. 2, 2022, 11:49 p.m. UTC
From: Justin Ruggles <justin.ruggles@gmail.com>

Using Range allows for getting the full file size from the
Content-Range header in the response, even if the server sends
back the response using chunked Transfer-Encoding, which does not
allow using Content-Length.
 libavformat/http.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/libavformat/http.c b/libavformat/http.c
index c89f8a5517..c79db955e8 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1469,10 +1469,10 @@  static int http_connect(URLContext *h, const char *path, const char *local_path,
     if (!has_header(s->headers, "\r\nAccept: "))
         av_bprintf(&request, "Accept: */*\r\n");
-    // Note: we send this on purpose even when s->off is 0 when we're probing,
+    // Note: we send the Range header on purpose, even when we're probing,
     // since it allows us to detect more reliably if a (non-conforming)
     // server supports seeking by analysing the reply headers.
-    if (!has_header(s->headers, "\r\nRange: ") && !post && (s->off > 0 || s->end_off || s->seekable == -1)) {
+    if (!has_header(s->headers, "\r\nRange: ") && !post && (s->off > 0 || s->end_off || s->seekable != 0)) {
         av_bprintf(&request, "Range: bytes=%"PRIu64"-", s->off);
         if (s->end_off)
             av_bprintf(&request, "%"PRId64, s->end_off - 1);