flush
authorMichael Wallner <mike@php.net>
Thu, 31 Oct 2013 14:54:56 +0000 (15:54 +0100)
committerMichael Wallner <mike@php.net>
Thu, 31 Oct 2013 14:54:56 +0000 (15:54 +0100)
http.md
http/Env/Request.md
http/Env/Request/__construct.md
http/Env/Request/getFiles.md [new file with mode: 0644]
http/Env/Request/getForm.md [new file with mode: 0644]
http/Env/Request/getQuery.md [new file with mode: 0644]
http/Exception.md [new file with mode: 0644]
http/QueryString.md [new file with mode: 0644]
http/QueryString/__construct.md [new file with mode: 0644]
http/QueryString/getGlobalInstance.md [new file with mode: 0644]
http/QueryString/getIterator.md [new file with mode: 0644]

diff --git a/http.md b/http.md
index e06a5bc6d952e0cc51200b853f60b3dc69e2ed74..f439b0d281fd2bcbace3fbb48534385b5412d6ee 100644 (file)
--- a/http.md
+++ b/http.md
@@ -1,6 +1,17 @@
 # pecl/http v2
 
-This documentation is work-in-progress.
+> **Note:** This documentation is work-in-progress.
+
+## About
+
+Extended HTTP support. Again. Keep in mind that it's got the major version 2, because it's incompatible with pecl_http v1.
+
+* Introduces the http namespace.
+* Message bodies have been remodeled to use PHP temporary streams instead of in-memory buffers.
+* The utterly misunderstood HttpResponse class has been reimplemented as http\Env\Response inheriting http\Message.
+* Currently, there's only one Exception class left, http\Exception.
+* Errors triggered by the extension can be configured statically by http\Object::$defaultErrorHandling or inherited http\Object->errorHandling.
+* The request ecosystem has been modularized to support different libraries, though for the moment only libcurl is supported.
 
 ## INI Directives:
 
index 63de534961ba1c4c492db0797b485bf502940568..57dc7878da35386595dd6bf81baf62861d3aef17 100644 (file)
@@ -1,5 +1,9 @@
 # class http\Env\Request extends http\Message
 
+The http\Env\Request class' instances represent the server's current HTTP request.
+
+See http\Message for inherited members.
+
 ## Constants:
 
 None.
index 307d73aa014ab29e1ab21a71a64eadc416d9ea6b..0e5707245e52476b458bc46d80b0e88be01e10c2 100644 (file)
@@ -1,7 +1,12 @@
-# void http\Env\Request::__construct(void)
+# void http\Env\Request::__construct()
 
-Instantiate the server's current HTTP request.
+Create an instance of the server's current HTTP request.
+
+Upon construction, the http\Env\Request acquires http\QueryString instances of  query paramters ($\_GET) and form parameters ($\_POST).
+
+It also compiles an array of uploaded files ($\_FILES) more comprehensive than the original $\_FILES array, see http\Env\Request::getFiles() for that matter.
 
 ## Params:
 
 None.
+
diff --git a/http/Env/Request/getFiles.md b/http/Env/Request/getFiles.md
new file mode 100644 (file)
index 0000000..82776b9
--- /dev/null
@@ -0,0 +1,45 @@
+# array http\Env\Request::getFiles()
+
+Retrieve the uploaded files list ($_FILES).
+
+## Params:
+
+None.
+
+## Returns:
+
+* array, the consolidated upload files array.
+
+## Example:
+
+Here's an example how the original $_FILES array and the http\Env\Request's files array compare:
+
+       $r = new http\Env\Request;
+       $f = array();
+
+       foreach ($_FILES as $name => $data) {
+               foreach ((array) $data["tmp_name"] as $i => $file) {
+                       $f[$name][$i] = array(
+                               "file" => $file,
+                               "name" => $data["name"][$i],
+                               "size" => $data["size"][$i],
+                               "type" => $data["type"][$i],
+                               "error"=> $data["error"][$i]
+                       );
+               }
+       }
+       assert($f == $r->getFiles());
+
+You can see that the second and third dimensions are swapped and ```tmp_name``` became ```file```, e.g:
+
+    array(
+               "upload" => array(
+                       array(
+                               "file" => "/tmp/phpXXXXXX",
+                               "name" => "picture.jpeg",
+                               "size" => 12345,
+                               "type" => "image/jpeg",
+                               "error"=> 0
+                       )
+               )
+       );
diff --git a/http/Env/Request/getForm.md b/http/Env/Request/getForm.md
new file mode 100644 (file)
index 0000000..2ccdd26
--- /dev/null
@@ -0,0 +1,25 @@
+# mixed http\Env\Request::getForm([string $name = NULL[, mixed $type = NULL[, mixed $defval = NULL[, bool $delete = false]]]])
+
+Retrieve a form value ($_POST).
+
+See http\QueryString::get() and http\QueryString::TYPE_* constants.
+
+## Params:
+
+* Optional string $name = NULL  
+  The key to retrieve the value for.
+* Optional mixed $type = NULL  
+  The type to cast the value to. See http\QueryString::TYPE_* constants.
+* Optional mixed $defval = NULL  
+  The default value to return if the key $name does not exist.
+* Optional bool $delete = false  
+  Whether to delete the entry from the querystring after retrieval.
+
+
+## Returns:
+
+* http\QueryString, if called without arguments.
+* string, the whole querystring if $name is of zero length.
+* mixed, $defval if the key $name does not exist.
+* mixed, the querystring value cast to $type if $type was specified and the key $name exists.
+* string, the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
diff --git a/http/Env/Request/getQuery.md b/http/Env/Request/getQuery.md
new file mode 100644 (file)
index 0000000..9196261
--- /dev/null
@@ -0,0 +1,25 @@
+# mixed http\Env\Request::getQuery([string $name = NULL[, mixed $type = NULL[, mixed $defval = NULL[, bool $delete = false]]]])
+
+Retrieve an URL query value ($_GET).
+
+See http\QueryString::get() and http\QueryString::TYPE_* constants.
+
+## Params:
+
+* Optional string $name = NULL  
+  The key to retrieve the value for.
+* Optional mixed $type = NULL  
+  The type to cast the value to. See http\QueryString::TYPE_* constants.
+* Optional mixed $defval = NULL  
+  The default value to return if the key $name does not exist.
+* Optional bool $delete = false  
+  Whether to delete the entry from the querystring after retrieval.
+
+
+## Returns:
+
+* http\QueryString, if called without arguments.
+* string, the whole querystring if $name is of zero length.
+* mixed, $defval if the key $name does not exist.
+* mixed, the querystring value cast to $type if $type was specified and the key $name exists.
+* string, the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING.
diff --git a/http/Exception.md b/http/Exception.md
new file mode 100644 (file)
index 0000000..7c18655
--- /dev/null
@@ -0,0 +1,3 @@
+# class http\Exception extends Exception
+
+The http extension's Exception.
diff --git a/http/QueryString.md b/http/QueryString.md
new file mode 100644 (file)
index 0000000..9541a35
--- /dev/null
@@ -0,0 +1,28 @@
+# class http\QueryString extends http\Object implements Serializable, ArrayAccess, IteratorAggregate
+
+The http\QueryString class provides versatile facilities to retrieve, use and manipulate query strings and form data.
+
+## Constants:
+
+* TYPE_BOOL  
+  Cast requested value to bool.
+* TYPE_INT  
+  Cast requested value to int.
+* TYPE_FLOAT  
+  Cast requested value to float.
+* TYPE_STRING  
+  Cast requested value to string.
+* TYPE_ARRAY  
+  Cast requested value to an array.
+* TYPE_OBJECT  
+  Cast requested value to an object.
+
+
+## Properties:
+
+* private $instance = NULL  
+  The global instance. See http\QueryString::getGlobalInstance().
+* private $queryArray = NULL  
+  The data array.
+
+
diff --git a/http/QueryString/__construct.md b/http/QueryString/__construct.md
new file mode 100644 (file)
index 0000000..8a1140b
--- /dev/null
@@ -0,0 +1,30 @@
+# void http\QueryString::__construct([mixed $params = NULL])
+
+Create an independent querystring instance.
+
+## Params:
+
+* Optional mixed $params = NULL  
+  The query parameters to use or parse.
+  
+## Throws:
+
+* http\Exception
+
+## Example:
+
+    $qs = new http\QueryString("foo=bar&a[]=1&a[]=2");
+    print_r($qs->toArray());
+
+Would yield:
+
+    Array
+    (
+        [foo] => bar
+        [a] => Array
+            (
+                [0] => 1
+                [1] => 2
+            )
+    
+    )
diff --git a/http/QueryString/getGlobalInstance.md b/http/QueryString/getGlobalInstance.md
new file mode 100644 (file)
index 0000000..1db996a
--- /dev/null
@@ -0,0 +1,15 @@
+# static http\QueryString http\QueryString::getGlobalInstance()
+
+Retrieve the global querystring instance referencing $_GET.
+
+## Params:
+
+None.
+
+## Returns:
+
+* http\QueryString, the http\QueryString::$instance
+
+## Throws:
+
+* http\Exception
diff --git a/http/QueryString/getIterator.md b/http/QueryString/getIterator.md
new file mode 100644 (file)
index 0000000..ab37865
--- /dev/null
@@ -0,0 +1,15 @@
+# Iterator http\QueryString::getIterator()
+
+Implements IteratorAggregate.
+
+## Params:
+
+None.
+
+## Returns:
+
+* ```RecursiveArrayIterator```
+
+## Throws:
+
+* http\Exception