diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2019-02-20 09:52:43 -0500 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2019-02-26 14:48:27 -0500 |
commit | 69fcc093c1241b5ee7711c56c9cd558832a7e491 (patch) | |
tree | 92e6bec3b8f4b3e13a4ddb33a61eac098e8b6f6f /libavformat | |
parent | f948082e5fc24b00c5b7dbf4493906f1e540a743 (diff) | |
download | ffmpeg-streaming-69fcc093c1241b5ee7711c56c9cd558832a7e491.zip ffmpeg-streaming-69fcc093c1241b5ee7711c56c9cd558832a7e491.tar.gz |
http: Do not try to make a new request when seeking past the end of the file
This avoids making invalid HTTP Range requests for a byte range past the
known end of the file during a seek. Those requests generally return a HTTP
response of 416 Range Not Satisfiable, which causes an error response.
Reference: https://tools.ietf.org/html/rfc7233
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/http.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/http.c b/libavformat/http.c index 072a6ce..ed0eb1c 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1691,6 +1691,13 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo if (s->off && h->is_streamed) return AVERROR(ENOSYS); + /* do not try to make a new connection if seeking past the end of the file */ + if (s->end_off || s->filesize != UINT64_MAX) { + uint64_t end_pos = s->end_off ? s->end_off : s->filesize; + if (s->off >= end_pos) + return s->off; + } + /* we save the old context in case the seek fails */ old_buf_size = s->buf_end - s->buf_ptr; memcpy(old_buf, s->buf_ptr, old_buf_size); |