- remove example scripts, as those can be extracted from tutorial.txt with extract.php
authorMichael Wallner <mike@php.net>
Thu, 10 Nov 2005 14:37:37 +0000 (14:37 +0000)
committerMichael Wallner <mike@php.net>
Thu, 10 Nov 2005 14:37:37 +0000 (14:37 +0000)
docs/examples/Bandwidth_Throttling.php [deleted file]
docs/examples/Cached_Responses.php [deleted file]
docs/examples/GET_Queries.php [deleted file]
docs/examples/KISS_XMLRPC_Client.php [deleted file]
docs/examples/Multipart_Posts.php [deleted file]
docs/examples/Parallel_Requests.php [deleted file]
docs/examples/Parallel_Requests_.php [deleted file]
docs/examples/Simple_Feed_Aggregator.php [deleted file]
package2.xml

diff --git a/docs/examples/Bandwidth_Throttling.php b/docs/examples/Bandwidth_Throttling.php
deleted file mode 100644 (file)
index 981272c..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<?php
-// send 5000 bytes every 0.2 seconds, i.e. max ~25kByte/s
-HttpResponse::setThrottleDelay(0.2);
-HttpResponse::setBufferSize(5000);
-HttpResponse::setCache(true);
-HttpResponse::setContentType('application/x-zip');
-HttpResponse::setFile('../archive.zip');
-HttpResponse::send();
-?>
diff --git a/docs/examples/Cached_Responses.php b/docs/examples/Cached_Responses.php
deleted file mode 100644 (file)
index 8ac2bcf..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-HttpResponse::setCacheControl('public');
-HttpResponse::setCache(true);
-HttpResponse::capture();
-
-print "This will be cached until content changes!\n";
-print "Note that this approach will only save the clients download time.\n";
-?>
diff --git a/docs/examples/GET_Queries.php b/docs/examples/GET_Queries.php
deleted file mode 100644 (file)
index 671f640..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-$r = new HttpRequest('http://www.google.com/search');
-
-// store Googles cookies in a dedicated file
-touch('google.txt');
-$r->setOptions(
-       array(  'cookiestore'   => 'google.txt',
-       )
-);
-
-$r->setQueryData(
-       array(  'q'             => '+"pecl_http" -msg -cvs -list',
-                       'hl'    => 'de'
-       )
-);
-
-// HttpRequest::send() returns an HttpMessage object
-// of type HttpMessage::RESPONSE or throws an exception
-try {
-       print $r->send()->getBody();
-} catch (HttpException $e) {
-       print $e;
-}
-?>
diff --git a/docs/examples/KISS_XMLRPC_Client.php b/docs/examples/KISS_XMLRPC_Client.php
deleted file mode 100644 (file)
index ac7498d..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-class XmlRpcClient
-{
-       public $namespace;
-       protected $request;
-
-       public function __construct($url, $namespace = '')
-       {
-               $this->namespace = $namespace;
-               $this->request = new HttpRequest($url, HTTP_METH_POST);
-               $this->request->setContentType('text/xml');
-       }
-
-       public function setOptions($options = array())
-       {
-               return $this->request->setOptions($options);
-       }
-
-       public function addOptions($options)
-       {
-               return $this->request->addOptions($options);
-       }
-
-       public function __call($method, $params)
-       {
-               if ($this->namespace) {
-                       $method = $this->namespace .'.'. $method;
-               }
-               $this->request->setRawPostData(xmlrpc_encode_request($method, $params));
-               $response = $this->request->send();
-               if ($response->getResponseCode() != 200) {
-                       throw new Exception($response->getBody(), $response->getResponseCode());
-               }
-               return xmlrpc_decode($response->getBody(), 'utf-8');
-       }
-       
-       public function getHistory()
-       {
-               return $this->request->getHistory();
-       }
-}
-
-?>
diff --git a/docs/examples/Multipart_Posts.php b/docs/examples/Multipart_Posts.php
deleted file mode 100644 (file)
index 2656b31..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-$r = new HttpRequest('http://dev.iworks.at/.print_request.php', HTTP_METH_POST);
-
-// if redirects is set to true, a single redirect is allowed;
-// one can set any reasonable count of allowed redirects
-$r->setOptions(
-       array(  'cookies'       => array('MyCookie' => 'has a value'),
-                       'redirect'      => true,
-       )
-);
-
-// common form data
-$r->setPostFields(
-       array(  'name'  => 'Mike',
-                       'mail'  => 'mike@php.net',
-       )
-);
-// add the file to post (form name, file name, file type)
-$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
-
-try {
-       print $r->send()->getBody();
-} catch (HttpException $e) {
-       print $e;
-}
-?>
diff --git a/docs/examples/Parallel_Requests.php b/docs/examples/Parallel_Requests.php
deleted file mode 100644 (file)
index d9b05f0..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?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_METH_HEAD));
-       $p->attach(new HttpRequest('http://pecl.php.net', HTTP_METH_HEAD));
-} catch (HttpException $e) {
-       print $e;
-       exit;
-}
-
-try {
-       $p->send();
-       // HttpRequestPool implements an iterator over attached HttpRequest objects
-       foreach ($p as $r) {
-               echo "Checking ", $r->getUrl(), " reported ", $r->getResponseCode(), "\n";
-       }
-} catch (HttpException $e) {
-       print $e;
-}
-?>
diff --git a/docs/examples/Parallel_Requests_.php b/docs/examples/Parallel_Requests_.php
deleted file mode 100644 (file)
index 8798c30..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-class Pool extends HttpRequestPool
-{
-       public function __construct()
-       {
-               parent::__construct(
-                       new HttpRequest('http://pear.php.net', HTTP_METH_HEAD),
-                       new HttpRequest('http://pecl.php.net', HTTP_METH_HEAD)
-               );
-
-               // HttpRequestPool methods socketPerform() and socketSelect() are
-               // protected;  one could use this approach to do something else
-               // while the requests are being executed
-               print "Executing requests";
-               for ($i = 0; $this->socketPerform(); $i++) {
-                       $i % 10 or print ".";
-                       if (!$this->socketSelect()) {
-                               throw new HttpException("Socket error!");
-                       }
-               }
-               print "\nDone!\n";
-       }
-}
-
-try {
-       foreach (new Pool as $r) {
-               echo "Checking ", $r->getUrl(), " reported ", $r->getResponseCode(), "\n";
-       }
-} catch (HttpException $ex) {
-       print $e;
-}
-?>
diff --git a/docs/examples/Simple_Feed_Aggregator.php b/docs/examples/Simple_Feed_Aggregator.php
deleted file mode 100644 (file)
index c28e838..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-class FeedAggregator
-{
-       public $directory;
-       protected $feeds = array();
-
-       public function __construct($directory = 'feeds')
-       {
-               $this->setDirectory($directory);
-       }
-
-       public function setDirectory($directory)
-       {
-               $this->directory = $directory;
-               foreach (glob($this->directory .'/*.xml') as $feed) {
-                       $this->feeds[basename($feed, '.xml')] = filemtime($feed);
-               }
-       }
-
-       public function url2name($url)
-       {
-               return preg_replace('/[^\w\.-]+/', '_', $url);
-       }
-       
-       public function hasFeed($url)
-       {
-               return isset($this->feeds[$this->url2name($url)]);
-       }
-
-       public function addFeed($url)
-       {
-               $r = $this->setupRequest($url);
-               $r->send();
-               $this->handleResponse($r);
-       }
-
-       public function addFeeds($urls)
-       {
-               $pool = new HttpRequestPool;
-               foreach ($urls as $url) {
-                       $pool->attach($r = $this->setupRequest($url));
-               }
-               $pool->send();
-
-               foreach ($pool as $request) {
-                       $this->handleResponse($request);
-               }
-       }
-
-       public function getFeed($url)
-       {
-               $this->addFeed($url);
-               return $this->loadFeed($this->url2name($url));
-       }
-
-       public function getFeeds($urls)
-       {
-               $feeds = array();
-               $this->addFeeds($urls);
-               foreach ($urls as $url) {
-                       $feeds[] = $this->loadFeed($this->url2name($url));
-               }
-               return $feeds;
-       }
-
-       protected function saveFeed($file, $contents)
-       {
-               if (file_put_contents($this->directory .'/'. $file .'.xml', $contents)) {
-                       $this->feeds[$file] = time();
-               } else {
-                       throw new Exception("Could not save feed contents to $file.xml");
-               }
-       }
-
-       protected function loadFeed($file)
-       {
-               if (isset($this->feeds[$file])) {
-                       if ($data = file_get_contents($this->directory .'/'. $file .'.xml')) {
-                               return $data;
-                       } else {
-                               throw new Exception("Could not load feed contents from $file.xml");
-                       }
-               } else {
-                       throw new Exception("Unknown feed/file $file.xml");
-               }
-       }
-
-       protected function setupRequest($url)
-       {
-               $r = new HttpRequest($url);
-               $r->setOptions(array('redirect' => true));
-
-               $file = $this->url2name($url);
-
-               if (isset($this->feeds[$file])) {
-                       $r->setOptions(array('lastmodified' => $this->feeds[$file]));
-               }
-
-               return $r;
-       }
-
-       protected function handleResponse(HttpRequest $r)
-       {
-               if ($r->getResponseCode() != 304) {
-                       if ($r->getResponseCode() != 200) {
-                               throw new Exception("Unexpected response code ". $r->getResponseCode());
-                       }
-                       if (!strlen($body = $r->getResponseBody())) {
-                               throw new Exception("Received empty feed from ". $r->getUrl());
-                       }
-                       $this->saveFeed($this->url2name($r->getUrl()), $body);
-               }
-       }
-}
-?>
index 787a62a17e5b64d06d044b65be916d497d92b22a..94bf0531e5edceb7d0f51168ccc8cf0894a8da52 100644 (file)
    <file role="doc" name="EXPERIMENTAL"/>
    <file role="doc" name="KnownIssues.txt"/>
    <file role="doc" name="docs/functions.html"/>
-   <file role="doc" name="docs/examples/Bandwidth_Throttling.php"/>
-   <file role="doc" name="docs/examples/Cached_Responses.php"/>
-   <file role="doc" name="docs/examples/GET_Queries.php"/>
-   <file role="doc" name="docs/examples/KISS_XMLRPC_Client.php"/>
-   <file role="doc" name="docs/examples/Multipart_Posts.php"/>
-   <file role="doc" name="docs/examples/Parallel_Requests.php"/>
-   <file role="doc" name="docs/examples/Parallel_Requests_.php"/>
-   <file role="doc" name="docs/examples/Simple_Feed_Aggregator.php"/>
    <file role="doc" name="docs/examples/extract.php"/>
    <file role="doc" name="docs/examples/tutorial.txt"/>