- don't destruct the zval right after construction in http_message_tostruct_recursive()
authorMichael Wallner <mike@php.net>
Fri, 14 Oct 2005 10:51:57 +0000 (10:51 +0000)
committerMichael Wallner <mike@php.net>
Fri, 14 Oct 2005 10:51:57 +0000 (10:51 +0000)
- add test

http_message_api.c
tests/parse_message_004.phpt [new file with mode: 0644]

index dd597fccf32dbc6a466d1c857f16611a0b34085d..d0c8f486947c41d6236854d5b5a9b00470b99149 100644 (file)
@@ -400,7 +400,6 @@ PHP_HTTP_API void _http_message_tostruct_recursive(http_message *msg, zval *obj
                }
                add_assoc_zval(&strct, "parentMessage", parent);
                http_message_tostruct_recursive(msg->parent, parent);
-               zval_ptr_dtor(&parent);
        } else {
                add_assoc_null(&strct, "parentMessage");
        }
diff --git a/tests/parse_message_004.phpt b/tests/parse_message_004.phpt
new file mode 100644 (file)
index 0000000..a684e84
--- /dev/null
@@ -0,0 +1,115 @@
+--TEST--
+http_parse_message() recursive
+--SKIPIF--
+<?php
+include 'skip.inc';
+?>
+--FILE--
+<?php
+
+echo "-TEST\n";
+$message =
+"HEAD / HTTP/1.1
+Host: www.example.com
+Accept: */*
+HTTP/1.1 200 Ok
+Server: Funky/1.0
+Content-Length: 10
+GET / HTTP/1.1
+Host: www.example.com
+Accept: */*
+HTTP/1.1 200 Ok
+Server: Funky/1.0
+Content-Length: 10
+
+1234567890
+";
+
+var_dump(http_parse_message($message));
+
+echo "Done\n";
+?>
+--EXPECTF--
+%sTEST
+object(stdClass)#1 (7) {
+  ["type"]=>
+  int(2)
+  ["httpVersion"]=>
+  float(1.1)
+  ["responseCode"]=>
+  int(200)
+  ["responseStatus"]=>
+  string(2) "Ok"
+  ["headers"]=>
+  array(2) {
+    ["Server"]=>
+    string(9) "Funky/1.0"
+    ["Content-Length"]=>
+    string(2) "10"
+  }
+  ["body"]=>
+  string(10) "1234567890"
+  ["parentMessage"]=>
+  object(stdClass)#2 (7) {
+    ["type"]=>
+    int(1)
+    ["httpVersion"]=>
+    float(1.1)
+    ["requestMethod"]=>
+    string(3) "GET"
+    ["requestUri"]=>
+    string(1) "/"
+    ["headers"]=>
+    array(2) {
+      ["Host"]=>
+      string(15) "www.example.com"
+      ["Accept"]=>
+      string(3) "*/*"
+    }
+    ["body"]=>
+    string(0) ""
+    ["parentMessage"]=>
+    object(stdClass)#3 (7) {
+      ["type"]=>
+      int(2)
+      ["httpVersion"]=>
+      float(1.1)
+      ["responseCode"]=>
+      int(200)
+      ["responseStatus"]=>
+      string(2) "Ok"
+      ["headers"]=>
+      array(2) {
+        ["Server"]=>
+        string(9) "Funky/1.0"
+        ["Content-Length"]=>
+        string(2) "10"
+      }
+      ["body"]=>
+      string(0) ""
+      ["parentMessage"]=>
+      object(stdClass)#4 (7) {
+        ["type"]=>
+        int(1)
+        ["httpVersion"]=>
+        float(1.1)
+        ["requestMethod"]=>
+        string(4) "HEAD"
+        ["requestUri"]=>
+        string(1) "/"
+        ["headers"]=>
+        array(2) {
+          ["Host"]=>
+          string(15) "www.example.com"
+          ["Accept"]=>
+          string(3) "*/*"
+        }
+        ["body"]=>
+        string(0) ""
+        ["parentMessage"]=>
+        NULL
+      }
+    }
+  }
+}
+Done