- bugs
authorMichael Wallner <mike@php.net>
Fri, 3 Jun 2005 09:18:55 +0000 (09:18 +0000)
committerMichael Wallner <mike@php.net>
Fri, 3 Jun 2005 09:18:55 +0000 (09:18 +0000)
tests/HttpRequest_002.phpt
tests/HttpRequest_003.phpt [new file with mode: 0644]
tests/split_response_001.phpt
tests/split_response_002.phpt [new file with mode: 0644]

index 52941506cb8ba1cdc5b43690adc1a9833a6787da..669197eb23cd19cca8efcdfc1c0110156f870660 100644 (file)
@@ -1,7 +1,7 @@
 --TEST--
-HttpRequest GET
+HttpRequest GET/POST
 --SKIPIF--
-<?php 
+<?php
 include 'skip.inc';
 (5 > (int) PHP_VERSION) and die('skip PHP5 is required for Http classes');
 ?>
@@ -10,6 +10,11 @@ include 'skip.inc';
 $r = new HttpRequest('http://www.google.com', HTTP_GET);
 var_dump($r->send());
 print_r($r->getResponseInfo());
+$r->setMethod(HTTP_POST);
+$r->addPostFields(array('q'=>'foobar','start'=>10));
+$r->send();
+var_dump($r->getResponseCode());
+var_dump(false != strstr($r->getResponseBody(), "Not Implemented"));
 ?>
 --EXPECTF--
 Content-type: text/html
@@ -43,3 +48,5 @@ Array
     [proxyauth_avail] => %d
     [num_connects] => %d
 )
+int(501)
+bool(true)
diff --git a/tests/HttpRequest_003.phpt b/tests/HttpRequest_003.phpt
new file mode 100644 (file)
index 0000000..cd6edd0
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+HttpRequest SSL
+--SKIPIF--
+<?php
+include 'skip.inc';
+(5 > (int) PHP_VERSION) and die('skip PHP5 is required for Http classes');
+?>
+--FILE--
+<?php
+$r = new HttpRequest('https://ssl.arweb.info/iworks/data.txt');
+$r->send();
+var_dump($r->getResponseBody());
+?>
+--EXPECTF--
+Content-type: text/html
+X-Powered-By: PHP/%s
+
+string(10) "1234567890"
index 799e23a2814248220abb37c4a91c4ce08bd814ee..95b8638437db9996dab5c1ba918c5f2a1f8e1cbc 100644 (file)
@@ -6,7 +6,9 @@ include 'skip.inc';
 ?>
 --FILE--
 <?php
-var_export(http_split_response("HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nContent-Language: de-AT\r\nDate: Sat, 22 Jan 2005 18:10:02 GMT\r\n\r\nHallo Du!"));
+$data = "HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nContent-Language: de-AT\r\nDate: Sat, 22 Jan 2005 18:10:02 GMT\r\n\r\nHallo Du!";
+var_export(http_split_response($data));
+echo "\nDone\n";
 ?>
 --EXPECTF--
 Content-type: text/html
@@ -22,3 +24,5 @@ array (
   ),
   1 => 'Hallo Du!',
 )
+Done
+
diff --git a/tests/split_response_002.phpt b/tests/split_response_002.phpt
new file mode 100644 (file)
index 0000000..820c1e6
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+http_split_response() list bug (mem-leaks)
+--SKIPIF--
+<?php
+include 'skip.inc';
+?>
+--FILE--
+<?php
+$data = "HTTP/1.1 200 Ok\r\nContent-Type: text/plain\r\nContent-Language: de-AT\r\nDate: Sat, 22 Jan 2005 18:10:02 GMT\r\n\r\nHallo Du!";
+// this generates mem-leaks - no idea how to fix them
+class t { 
+       var $r = array(); 
+       function fail($data) {
+               list($this->r['headers'], $this->r['body']) = http_split_response($data);
+       }
+}
+
+$t = new t;
+$t->fail($data);
+echo "Done\n";
+?>
+--EXPECTF--
+Content-type: text/html
+X-Powered-By: PHP/%s
+
+Done
+