aboutsummaryrefslogtreecommitdiff
path: root/models/Auth.old/Yadis/HTTPFetcher.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2011-12-11 06:38:23 -0500
committerCash Costello <cash.costello@gmail.com>2011-12-11 06:38:23 -0500
commitd9bf22a0e29c2a70049443a0ae8521a2c0492c8b (patch)
treec7599a9169d5def7df56c480ad6d67f312443d6f /models/Auth.old/Yadis/HTTPFetcher.php
downloadelgg-d9bf22a0e29c2a70049443a0ae8521a2c0492c8b.tar.gz
elgg-d9bf22a0e29c2a70049443a0ae8521a2c0492c8b.tar.bz2
initial commit for git repository
Diffstat (limited to 'models/Auth.old/Yadis/HTTPFetcher.php')
-rw-r--r--models/Auth.old/Yadis/HTTPFetcher.php114
1 files changed, 114 insertions, 0 deletions
diff --git a/models/Auth.old/Yadis/HTTPFetcher.php b/models/Auth.old/Yadis/HTTPFetcher.php
new file mode 100644
index 000000000..97617bf32
--- /dev/null
+++ b/models/Auth.old/Yadis/HTTPFetcher.php
@@ -0,0 +1,114 @@
+<?php
+
+/**
+ * This module contains the HTTP fetcher interface
+ *
+ * PHP versions 4 and 5
+ *
+ * LICENSE: See the COPYING file included in this distribution.
+ *
+ * @package OpenID
+ * @author JanRain, Inc. <openid@janrain.com>
+ * @copyright 2005 Janrain, Inc.
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL
+ */
+
+class Auth_Yadis_HTTPResponse {
+ function Auth_Yadis_HTTPResponse($final_url = null, $status = null,
+ $headers = null, $body = null)
+ {
+ $this->final_url = $final_url;
+ $this->status = $status;
+ $this->headers = $headers;
+ $this->body = $body;
+ }
+}
+
+/**
+ * This class is the interface for HTTP fetchers the Yadis library
+ * uses. This interface is only important if you need to write a new
+ * fetcher for some reason.
+ *
+ * @access private
+ * @package OpenID
+ */
+class Auth_Yadis_HTTPFetcher {
+
+ var $timeout = 20; // timeout in seconds.
+
+ /**
+ * Return whether a URL should be allowed. Override this method to
+ * conform to your local policy.
+ *
+ * By default, will attempt to fetch any http or https URL.
+ */
+ function allowedURL($url)
+ {
+ return $this->URLHasAllowedScheme($url);
+ }
+
+ /**
+ * Does this fetcher implementation (and runtime) support fetching
+ * HTTPS URLs? May inspect the runtime environment.
+ *
+ * @return bool $support True if this fetcher supports HTTPS
+ * fetching; false if not.
+ */
+ function supportsSSL()
+ {
+ trigger_error("not implemented", E_USER_ERROR);
+ }
+
+ /**
+ * Is this an https URL?
+ *
+ * @access private
+ */
+ function isHTTPS($url)
+ {
+ return (bool)preg_match('/^https:\/\//i', $url);
+ }
+
+ /**
+ * Is this an http or https URL?
+ *
+ * @access private
+ */
+ function URLHasAllowedScheme($url)
+ {
+ return (bool)preg_match('/^https?:\/\//i', $url);
+ }
+
+ /**
+ * @access private
+ */
+ function _findRedirect($headers)
+ {
+ foreach ($headers as $line) {
+ if (strpos(strtolower($line), "location: ") === 0) {
+ $parts = explode(" ", $line, 2);
+ return $parts[1];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Fetches the specified URL using optional extra headers and
+ * returns the server's response.
+ *
+ * @param string $url The URL to be fetched.
+ * @param array $extra_headers An array of header strings
+ * (e.g. "Accept: text/html").
+ * @return mixed $result An array of ($code, $url, $headers,
+ * $body) if the URL could be fetched; null if the URL does not
+ * pass the URLHasAllowedScheme check or if the server's response
+ * is malformed.
+ */
+ function get($url, $headers)
+ {
+ trigger_error("not implemented", E_USER_ERROR);
+ }
+}
+
+?> \ No newline at end of file