Commit 69fcc093 authored by Justin Ruggles's avatar Justin Ruggles Committed by Vittorio Giovara

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/rfc7233Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
parent f948082e
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment