- add missing support for raw post data (HttpRequest)
[m6w6/ext-http] / docs / examples / Parallel_Requests.php
diff --git a/docs/examples/Parallel_Requests.php b/docs/examples/Parallel_Requests.php
new file mode 100644 (file)
index 0000000..962ea05
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+try {
+       $p = new HttpRequestPool;
+       // if you want to set _any_ options of the HttpRequest object,
+       // you need to do so *prior attaching* to the request pool!
+       $p->attach(new HttpRequest('http://pear.php.net', HTTP_HEAD));
+       $p->attach(new HttpRequest('http://pecl.php.net', HTTP_HEAD));
+} catch (HttpException $e) {
+       print $e;
+       exit;
+}
+
+try {
+       $p->send();
+       // HttpRequestPool implements an iterator over attached HttpRequest objects
+       foreach ($p as $r) {
+               print "Checking ", $r->getUrl(), " reported ", $r->getResponseCode(), "\n";
+       }
+} catch (HttpException $e) {
+       print $e;
+}
+?>