Commit 38990026 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

https: use token helpers

parent b32d5548
...@@ -206,12 +206,8 @@ bool vlc_http_file_can_seek(struct vlc_http_file *file) ...@@ -206,12 +206,8 @@ bool vlc_http_file_can_seek(struct vlc_http_file *file)
if (status == 206 || status == 416) if (status == 206 || status == 416)
return true; /* Partial Content */ return true; /* Partial Content */
const char *str = vlc_http_msg_get_header(file->resp, "Accept-Ranges"); return vlc_http_msg_get_token(file->resp, "Accept-Ranges",
/* FIXME: tokenize */ "bytes") != NULL;
if (str != NULL && !vlc_ascii_strcasecmp(str, "bytes"))
return true;
return false;
} }
char *vlc_http_file_get_type(struct vlc_http_file *file) char *vlc_http_file_get_type(struct vlc_http_file *file)
......
...@@ -169,6 +169,7 @@ static struct vlc_http_msg *vlc_h1_stream_wait(struct vlc_http_stream *stream) ...@@ -169,6 +169,7 @@ static struct vlc_http_msg *vlc_h1_stream_wait(struct vlc_http_stream *stream)
{ {
struct vlc_h1_conn *conn = vlc_h1_stream_conn(stream); struct vlc_h1_conn *conn = vlc_h1_stream_conn(stream);
struct vlc_http_msg *resp; struct vlc_http_msg *resp;
const char *str;
size_t len; size_t len;
int minor; int minor;
...@@ -197,18 +198,19 @@ static struct vlc_http_msg *vlc_h1_stream_wait(struct vlc_http_stream *stream) ...@@ -197,18 +198,19 @@ static struct vlc_http_msg *vlc_h1_stream_wait(struct vlc_http_stream *stream)
if (minor >= 1) if (minor >= 1)
{ {
const char *str = vlc_http_msg_get_header(resp, "Connection"); if (vlc_http_msg_get_token(resp, "Connection", "close") != NULL)
if (str != NULL && strcasestr(str, "close")) /* FIXME: tokenize */
conn->connection_close = true; conn->connection_close = true;
/* FIXME: tokenize, check if chunked is _last_ */ str = vlc_http_msg_get_token(resp, "Transfer-Encoding", "chunked");
str = vlc_http_msg_get_header(resp, "Transfer-Encoding"); if (str != NULL)
if (str != NULL && strcasestr(str, "chunked"))
{ {
if (vlc_http_next_token(str) != NULL)
return vlc_h1_stream_fatal(conn); /* unsupported TE */
assert(conn->content_length == UINTMAX_MAX); assert(conn->content_length == UINTMAX_MAX);
stream = vlc_chunked_open(stream, conn->conn.tls); stream = vlc_chunked_open(stream, conn->conn.tls);
if (unlikely(stream == NULL)) if (unlikely(stream == NULL))
return NULL; return vlc_h1_stream_fatal(conn);
} }
} }
else else
......
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