* Fixed a bug which required "=" in Content-Range response message headers
authorMichael Wallner <mike@php.net>
Wed, 9 Nov 2005 16:05:23 +0000 (16:05 +0000)
committerMichael Wallner <mike@php.net>
Wed, 9 Nov 2005 16:05:23 +0000 (16:05 +0000)
http_message_api.c
package2.xml
tests/parse_message_005.phpt [new file with mode: 0644]

index f7492280357be5e32fdd79b9e7ed6ad2c7537668..d175201913996af652c287015b218d1de52c1842 100644 (file)
@@ -188,7 +188,8 @@ PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char
                if (c = http_message_header(msg, "Content-Range")) {
                        ulong total = 0, start = 0, end = 0, len = 0;
                        
-                       if (!strncasecmp(Z_STRVAL_P(c), "bytes=", lenof("bytes="))) {
+                       if (!strncasecmp(Z_STRVAL_P(c), "bytes", lenof("bytes")) && 
+                                       (Z_STRVAL_P(c)[lenof("bytes")] == '=' || Z_STRVAL_P(c)[lenof("bytes")] == ' ')) {
                                char *total_at = NULL, *end_at = NULL;
                                char *start_at = Z_STRVAL_P(c) + lenof("bytes=");
                                
index 6dd18271cdaaa0baa89cf12fe5165b0414b6e576..c6486374e4f2b0c0643b1a8112a114ebe36aff99 100644 (file)
@@ -46,6 +46,7 @@
 
 * Fixed a bug that caused a warning about an invalid curl handle at HttpRequestPool destruction
 * Fixed a bug with http_get_request_headers() modifying $_SERVER array
+* Fixed a bug which required "=" in Content-Range response message headers
 ]]></notes>
  <contents>
   <dir name="/">
diff --git a/tests/parse_message_005.phpt b/tests/parse_message_005.phpt
new file mode 100644 (file)
index 0000000..0ddeb05
--- /dev/null
@@ -0,0 +1,60 @@
+--TEST--
+http_parse_message() content range header w/(o) =
+--SKIPIF--
+<?php
+include 'skip.inc';
+?>
+--FILE--
+<?php
+echo "-TEST\n";
+print_r(http_parse_message(
+"
+HTTP/1.1 206
+Server: Funky/1.0
+Content-Range: bytes=0-0/100
+
+1
+
+HTTP/1.1 206
+Server: Funky/1.0
+Content-Range: bytes 0-0/100
+
+1
+
+"
+));
+echo "Done\n";
+?>
+--EXPECTF--
+%sTEST
+stdClass Object
+(
+    [type] => 2
+    [httpVersion] => 1.1
+    [responseCode] => 206
+    [responseStatus] => 
+    [headers] => Array
+        (
+            [Server] => Funky/1.0
+            [Content-Range] => bytes 0-0/100
+        )
+
+    [body] => 1
+    [parentMessage] => stdClass Object
+        (
+            [type] => 2
+            [httpVersion] => 1.1
+            [responseCode] => 206
+            [responseStatus] => 
+            [headers] => Array
+                (
+                    [Server] => Funky/1.0
+                    [Content-Range] => bytes=0-0/100
+                )
+
+            [body] => 1
+            [parentMessage] => 
+        )
+
+)
+Done