Browse Source

http: allow short response byte range

RFC9110 specifies that a client must handle a shorter response range
than requested in all circumstanges. Previously, RFC7233 only required
that behaviour for multipart ranges, which VLC did not use.

This matches the newer specification: VLC will try to resume from the
last received offset not only on unexpected error, but also on short
response.

Fixes #28627.

(cherry picked from commit 90dc0a023f)
cherry-pick-c5513cf9
Rémi Denis-Courmont 2 years ago
parent
commit
d9b0f2b638
  1. 23
      modules/access/http/file.c

23
modules/access/http/file.c

@ -235,20 +235,21 @@ block_t *vlc_http_file_read(struct vlc_http_resource *res)
block_t *block = vlc_http_res_read(res);
if (block == vlc_http_error)
{ /* Automatically reconnect on error if server supports seek */
if (res->response != NULL
&& vlc_http_msg_can_seek(res->response)
&& file->offset < vlc_http_msg_get_file_size(res->response)
&& vlc_http_file_seek(res, file->offset) == 0)
block = vlc_http_res_read(res);
block = NULL;
/* Automatically resume on short response or error if possible */
if (block == NULL && res->response != NULL
&& vlc_http_msg_can_seek(res->response)
&& file->offset < vlc_http_msg_get_file_size(res->response)
&& vlc_http_file_seek(res, file->offset) == 0)
{
block = vlc_http_res_read(res);
if (block == vlc_http_error)
return NULL;
block = NULL; /* Non-recovered error */
}
if (block == NULL)
return NULL; /* End of stream */
file->offset += block->i_buffer;
if (block != NULL)
file->offset += block->i_buffer;
return block;
}

Loading…
Cancel
Save