]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - inc/3rdparty/libraries/humble-http-agent/SimplePie_HumbleHttpAgent.php
[change] we now use Full-Text RSS 3.1, thank you so much @fivefilters
[github/wallabag/wallabag.git] / inc / 3rdparty / libraries / humble-http-agent / SimplePie_HumbleHttpAgent.php
similarity index 96%
rename from inc/3rdparty/humble-http-agent/SimplePie_HumbleHttpAgent.php
rename to inc/3rdparty/libraries/humble-http-agent/SimplePie_HumbleHttpAgent.php
index ce76a929f90d4ca60f235fcb61fb356d4f514eae..ecd46d5f8af37f38f56bdd23d7b23a0a945fd090 100644 (file)
@@ -1,79 +1,79 @@
-<?php
-/**
- * Humble HTTP Agent extension for SimplePie_File
- * 
- * This class is designed to extend and override SimplePie_File
- * in order to prevent duplicate HTTP requests being sent out.
- * The idea is to initialise an instance of Humble HTTP Agent
- * and attach it, to a static class variable, of this class.
- * SimplePie will then automatically initialise this class
- * 
- * @date 2011-02-28
- */
-
-class SimplePie_HumbleHttpAgent extends SimplePie_File
-{
-       protected static $agent;
-       var $url;
-       var $useragent;
-       var $success = true;
-       var $headers = array();
-       var $body;
-       var $status_code;
-       var $redirects = 0;
-       var $error;
-       var $method = SIMPLEPIE_FILE_SOURCE_NONE;
-
-       public static function set_agent(HumbleHttpAgent $agent) {
-               self::$agent = $agent;
-       }
-       
-       public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
-               if (class_exists('idna_convert'))
-               {
-                       $idn = new idna_convert();
-                       $parsed = SimplePie_Misc::parse_url($url);
-                       $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);
-               }
-               $this->url = $url;
-               $this->useragent = $useragent;
-               if (preg_match('/^http(s)?:\/\//i', $url))
-               {
-                       if (!is_array($headers))
-                       {
-                               $headers = array();
-                       }
-                       $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
-                       $headers2 = array();
-                       foreach ($headers as $key => $value) {
-                               $headers2[] = "$key: $value";
-                       }
-                       //TODO: allow for HTTP headers
-                       // curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);
-
-                       $response = self::$agent->get($url);
-                       
-                       if ($response === false || !isset($response['status_code'])) {
-                               $this->error = 'failed to fetch URL';
-                               $this->success = false;
-                       } else {
-                               // The extra lines at the end are there to satisfy SimplePie's HTTP parser.
-                               // The class expects a full HTTP message, whereas we're giving it only
-                               // headers - the new lines indicate the start of the body.
-                               $parser = new SimplePie_HTTP_Parser($response['headers']."\r\n\r\n");
-                               if ($parser->parse()) {
-                                       $this->headers = $parser->headers;
-                                       //$this->body = $parser->body;
-                                       $this->body = $response['body'];
-                                       $this->status_code = $parser->status_code;
-                               }
-                       }
-               }
-               else
-               {
-                       $this->error = 'invalid URL';
-                       $this->success = false;
-               }
-       }
-}
+<?php\r
+/**\r
+ * Humble HTTP Agent extension for SimplePie_File\r
+ * \r
+ * This class is designed to extend and override SimplePie_File\r
+ * in order to prevent duplicate HTTP requests being sent out.\r
+ * The idea is to initialise an instance of Humble HTTP Agent\r
+ * and attach it, to a static class variable, of this class.\r
+ * SimplePie will then automatically initialise this class\r
+ * \r
+ * @date 2011-02-28\r
+ */\r
+\r
+class SimplePie_HumbleHttpAgent extends SimplePie_File\r
+{\r
+       protected static $agent;\r
+       var $url;\r
+       var $useragent;\r
+       var $success = true;\r
+       var $headers = array();\r
+       var $body;\r
+       var $status_code;\r
+       var $redirects = 0;\r
+       var $error;\r
+       var $method = SIMPLEPIE_FILE_SOURCE_NONE;\r
+\r
+       public static function set_agent(HumbleHttpAgent $agent) {\r
+               self::$agent = $agent;\r
+       }\r
+       \r
+       public function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {\r
+               if (class_exists('idna_convert'))\r
+               {\r
+                       $idn = new idna_convert();\r
+                       $parsed = SimplePie_Misc::parse_url($url);\r
+                       $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']);\r
+               }\r
+               $this->url = $url;\r
+               $this->useragent = $useragent;\r
+               if (preg_match('/^http(s)?:\/\//i', $url))\r
+               {\r
+                       if (!is_array($headers))\r
+                       {\r
+                               $headers = array();\r
+                       }\r
+                       $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;\r
+                       $headers2 = array();\r
+                       foreach ($headers as $key => $value) {\r
+                               $headers2[] = "$key: $value";\r
+                       }\r
+                       //TODO: allow for HTTP headers\r
+                       // curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2);\r
+\r
+                       $response = self::$agent->get($url);\r
+                       \r
+                       if ($response === false || !isset($response['status_code'])) {\r
+                               $this->error = 'failed to fetch URL';\r
+                               $this->success = false;\r
+                       } else {\r
+                               // The extra lines at the end are there to satisfy SimplePie's HTTP parser.\r
+                               // The class expects a full HTTP message, whereas we're giving it only\r
+                               // headers - the new lines indicate the start of the body.\r
+                               $parser = new SimplePie_HTTP_Parser($response['headers']."\r\n\r\n");\r
+                               if ($parser->parse()) {\r
+                                       $this->headers = $parser->headers;\r
+                                       //$this->body = $parser->body;\r
+                                       $this->body = $response['body'];\r
+                                       $this->status_code = $parser->status_code;\r
+                               }\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       $this->error = 'invalid URL';\r
+                       $this->success = false;\r
+               }\r
+       }\r
+}\r
 ?>
\ No newline at end of file