[vlc-commits] https: use token helpers

Rémi Denis-Courmont git at videolan.org
Sun Dec 20 14:25:42 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Dec 20 15:23:52 2015 +0200| [38990026db77346d172d6bc3355d88da82debb08] | committer: Rémi Denis-Courmont

https: use token helpers

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=38990026db77346d172d6bc3355d88da82debb08
---

 modules/access/http/file.c   |    8 ++------
 modules/access/http/h1conn.c |   14 ++++++++------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/modules/access/http/file.c b/modules/access/http/file.c
index 4d3d20a..5695c7f 100644
--- a/modules/access/http/file.c
+++ b/modules/access/http/file.c
@@ -206,12 +206,8 @@ bool vlc_http_file_can_seek(struct vlc_http_file *file)
     if (status == 206 || status == 416)
         return true; /* Partial Content */
 
-    const char *str = vlc_http_msg_get_header(file->resp, "Accept-Ranges");
-    /* FIXME: tokenize */
-    if (str != NULL && !vlc_ascii_strcasecmp(str, "bytes"))
-        return true;
-
-    return false;
+    return vlc_http_msg_get_token(file->resp, "Accept-Ranges",
+                                  "bytes") != NULL;
 }
 
 char *vlc_http_file_get_type(struct vlc_http_file *file)
diff --git a/modules/access/http/h1conn.c b/modules/access/http/h1conn.c
index 89ab73e..2a8246f 100644
--- a/modules/access/http/h1conn.c
+++ b/modules/access/http/h1conn.c
@@ -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_http_msg *resp;
+    const char *str;
     size_t len;
     int minor;
 
@@ -197,18 +198,19 @@ static struct vlc_http_msg *vlc_h1_stream_wait(struct vlc_http_stream *stream)
 
     if (minor >= 1)
     {
-        const char *str = vlc_http_msg_get_header(resp, "Connection");
-        if (str != NULL && strcasestr(str, "close")) /* FIXME: tokenize */
+        if (vlc_http_msg_get_token(resp, "Connection", "close") != NULL)
             conn->connection_close = true;
 
-        /* FIXME: tokenize, check if chunked is _last_ */
-        str = vlc_http_msg_get_header(resp, "Transfer-Encoding");
-        if (str != NULL && strcasestr(str, "chunked"))
+        str = vlc_http_msg_get_token(resp, "Transfer-Encoding", "chunked");
+        if (str != NULL)
         {
+            if (vlc_http_next_token(str) != NULL)
+                return vlc_h1_stream_fatal(conn); /* unsupported TE */
+
             assert(conn->content_length == UINTMAX_MAX);
             stream = vlc_chunked_open(stream, conn->conn.tls);
             if (unlikely(stream == NULL))
-                return NULL;
+                return vlc_h1_stream_fatal(conn);
         }
     }
     else



More information about the vlc-commits mailing list