[xiph-commits] r14006 - icecast/trunk/icecast/src

karl at svn.xiph.org karl at svn.xiph.org
Wed Oct 17 16:49:14 PDT 2007


Author: karl
Date: 2007-10-17 16:49:14 -0700 (Wed, 17 Oct 2007)
New Revision: 14006

Modified:
   icecast/trunk/icecast/src/fserve.c
Log:
updates to range header handling. closes #1246, #810


Modified: icecast/trunk/icecast/src/fserve.c
===================================================================
--- icecast/trunk/icecast/src/fserve.c	2007-10-17 03:18:34 UTC (rev 14005)
+++ icecast/trunk/icecast/src/fserve.c	2007-10-17 23:49:14 UTC (rev 14006)
@@ -33,6 +33,7 @@
 #include <winsock2.h>
 #include <windows.h>
 #define snprintf _snprintf
+#define strncasecmp _strnicmp
 #define S_ISREG(mode)  ((mode) & _S_IFREG)
 #endif
 
@@ -501,8 +502,12 @@
     content_length = (int64_t)file_buf.st_size;
     range = httpp_getvar (httpclient->parser, "range");
 
+    /* full http range handling is currently not done but we deal with the common case */
     if (range != NULL) {
-        ret = sscanf(range, "bytes=" FORMAT_INT64 "-", &rangenumber);
+        ret = 0;
+        if (strncasecmp (range, "bytes=", 6) == 0)
+            ret = sscanf (range+6, FORMAT_INT64 "-", &rangenumber);
+
         if (ret != 1) {
             /* format not correct, so lets just assume
                we start from the beginning */
@@ -542,6 +547,7 @@
                 bytes = snprintf (httpclient->refbuf->data, BUFSIZE,
                     "HTTP/1.1 206 Partial Content\r\n"
                     "Date: %s\r\n"
+                    "Accept-Ranges: bytes\r\n"
                     "Content-Length: " FORMAT_INT64 "\r\n"
                     "Content-Range: bytes " FORMAT_INT64 \
                     "-" FORMAT_INT64 "/" FORMAT_INT64 "\r\n"
@@ -567,6 +573,7 @@
         httpclient->respcode = 200;
         bytes = snprintf (httpclient->refbuf->data, BUFSIZE,
             "HTTP/1.0 200 OK\r\n"
+            "Accept-Ranges: bytes\r\n"
             "Content-Length: " FORMAT_INT64 "\r\n"
             "Content-Type: %s\r\n\r\n",
             content_length,



More information about the commits mailing list