http: Consider the stream as seekable if the reply contains Accept-Ranges: bytes

Message ID 1315127011-39115-1-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Sept. 4, 2011, 9:03 a.m.
From: Stefan Fritsch <sf@sfritsch.de>

The initial request contains "Range: 0-", which servers normally
have responded with "HTTP/1.1 206 Partial Content" reply with
a Content-Range header, which was used as indicator for seekability.

Apache, since 2.2.20, responds with "HTTP/1.1 200 OK" for these
requests, which is more friendly to caches and proxies, but the
seekability still is indicated via the Accept-Ranges: bytes header.
---
 libavformat/http.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Luca Barbato Sept. 4, 2011, 9:07 a.m. | #1
On 9/4/11 11:03 AM, Martin Storsjö wrote:
> From: Stefan Fritsch<sf@sfritsch.de>
>
> The initial request contains "Range: 0-", which servers normally
> have responded with "HTTP/1.1 206 Partial Content" reply with
> a Content-Range header, which was used as indicator for seekability.
>
> Apache, since 2.2.20, responds with "HTTP/1.1 200 OK" for these
> requests, which is more friendly to caches and proxies, but the
> seekability still is indicated via the Accept-Ranges: bytes header.
> ---

you beat me at it =)

The patch is ok, maybe there is a space too much here and there (do we 
put space between functions and '(' ) ?

lu
Martin Storsjö Sept. 4, 2011, 9:29 a.m. | #2
On Sun, 4 Sep 2011, Luca Barbato wrote:

> On 9/4/11 11:03 AM, Martin Storsjö wrote:
> > From: Stefan Fritsch<sf@sfritsch.de>
> > 
> > The initial request contains "Range: 0-", which servers normally
> > have responded with "HTTP/1.1 206 Partial Content" reply with
> > a Content-Range header, which was used as indicator for seekability.
> > 
> > Apache, since 2.2.20, responds with "HTTP/1.1 200 OK" for these
> > requests, which is more friendly to caches and proxies, but the
> > seekability still is indicated via the Accept-Ranges: bytes header.
> > ---
> 
> you beat me at it =)
> 
> The patch is ok, maybe there is a space too much here and there (do we put
> space between functions and '(' ) ?

Ah, yes, pushed with that fixed up.

// Martin

Patch

diff --git a/libavformat/http.c b/libavformat/http.c
index aa8c665..4952ced 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -265,6 +265,8 @@  static int process_line(URLContext *h, char *line, int line_count,
                     s->filesize = atoll(slash+1);
             }
             h->is_streamed = 0; /* we _can_ in fact seek */
+        } else if (!strcasecmp (tag, "Accept-Ranges") && !strncmp (p, "bytes", 5)) {
+            h->is_streamed = 0;
         } else if (!strcasecmp (tag, "Transfer-Encoding") && !strncasecmp(p, "chunked", 7)) {
             s->filesize = -1;
             s->chunksize = 0;