diff options
author | tailor <cygnus@janrain.com> | 2006-08-15 21:22:12 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2006-08-15 21:22:12 +0000 |
commit | 6f08a6797b05eed5291dae3617472717244d194c (patch) | |
tree | f0c90bd2686f4f4eeeba79227545c9f571f6bd33 | |
parent | af8628d2f6cd1588ff6926f5ed163ae6e3dd4704 (diff) | |
download | php-openid-6f08a6797b05eed5291dae3617472717244d194c.zip php-openid-6f08a6797b05eed5291dae3617472717244d194c.tar.gz php-openid-6f08a6797b05eed5291dae3617472717244d194c.tar.bz2 |
[project @ Moved curl fetcher detection code into Yadis]
-rw-r--r-- | Auth/OpenID.php | 15 | ||||
-rw-r--r-- | Auth/OpenID/Consumer.php | 2 | ||||
-rw-r--r-- | Services/Yadis/ParanoidHTTPFetcher.php | 10 | ||||
-rw-r--r-- | Services/Yadis/Yadis.php | 8 | ||||
-rw-r--r-- | examples/detect.php | 4 |
5 files changed, 9 insertions, 30 deletions
diff --git a/Auth/OpenID.php b/Auth/OpenID.php index 3cd296f..a56835a 100644 --- a/Auth/OpenID.php +++ b/Auth/OpenID.php @@ -112,21 +112,6 @@ $_Auth_OpenID_namespaces = array('openid', class Auth_OpenID { /** - * Factory function that will return an instance of the - * appropriate HTTP fetcher - */ - function getHTTPFetcher() - { - if (defined('Services_Yadis_CURL_PRESENT') && - Services_Yadis_CURL_PRESENT) { - $fetcher = new Services_Yadis_ParanoidHTTPFetcher(); - } else { - $fetcher = new Services_Yadis_PlainHTTPFetcher(); - } - return $fetcher; - } - - /** * Rename query arguments back to 'openid.' from 'openid_' * * @access private diff --git a/Auth/OpenID/Consumer.php b/Auth/OpenID/Consumer.php index 8e28c2f..88f8889 100644 --- a/Auth/OpenID/Consumer.php +++ b/Auth/OpenID/Consumer.php @@ -463,7 +463,7 @@ class Auth_OpenID_GenericConsumer { !(defined('Auth_OpenID_NO_MATH_SUPPORT') || $this->store->isDumb()); - $this->fetcher = Auth_OpenID::getHTTPFetcher(); + $this->fetcher = Services_Yadis_Yadis::getHTTPFetcher(); } function begin($service_endpoint) diff --git a/Services/Yadis/ParanoidHTTPFetcher.php b/Services/Yadis/ParanoidHTTPFetcher.php index 5ddd129..080711b 100644 --- a/Services/Yadis/ParanoidHTTPFetcher.php +++ b/Services/Yadis/ParanoidHTTPFetcher.php @@ -19,11 +19,6 @@ require_once "Services/Yadis/HTTPFetcher.php"; /** - * Define this based on whether the CURL extension is available. - */ -define('Services_Yadis_CURL_PRESENT', function_exists('curl_init')); - -/** * A paranoid {@link Services_Yadis_HTTPFetcher} class which uses CURL * for fetching. * @@ -32,11 +27,6 @@ define('Services_Yadis_CURL_PRESENT', function_exists('curl_init')); class Services_Yadis_ParanoidHTTPFetcher extends Services_Yadis_HTTPFetcher { function Services_Yadis_ParanoidHTTPFetcher() { - if (!Services_Yadis_CURL_PRESENT) { - trigger_error("Cannot use this class; CURL extension not found", - E_USER_ERROR); - } - $this->headers = array(); $this->data = ""; diff --git a/Services/Yadis/Yadis.php b/Services/Yadis/Yadis.php index 78fb11c..338bb3a 100644 --- a/Services/Yadis/Yadis.php +++ b/Services/Yadis/Yadis.php @@ -121,8 +121,7 @@ class Services_Yadis_Yadis { */ function getHTTPFetcher($timeout = 20) { - if (defined('Services_Yadis_CURL_PRESENT') && - Services_Yadis_CURL_PRESENT) { + if (Services_Yadis_Yadis::curlPresent()) { $fetcher = new Services_Yadis_ParanoidHTTPFetcher($timeout); } else { $fetcher = new Services_Yadis_PlainHTTPFetcher($timeout); @@ -130,6 +129,11 @@ class Services_Yadis_Yadis { return $fetcher; } + function curlPresent() + { + return function_exists('curl_init'); + } + /** * @access private */ diff --git a/examples/detect.php b/examples/detect.php index ea7ecdc..cc3a00c 100644 --- a/examples/detect.php +++ b/examples/detect.php @@ -382,7 +382,7 @@ function detect_xml($r, &$out) function detect_fetcher($r, &$out) { $out .= $r->h2('HTTP Fetching'); - if (Auth_OpenID_CURL_PRESENT) { + if (Services_Yadis_Yadis::curlPresent()) { // XXX: actually fetch a URL. $out .= $r->p('This PHP installation has support for libcurl. Good.'); } else { @@ -395,7 +395,7 @@ function detect_fetcher($r, &$out) 'for PHP.'); } $ok = true; - $fetcher = Auth_OpenID::getHTTPFetcher(); + $fetcher = Services_Yadis_Yadis::getHTTPFetcher(); $fetch_url = 'http://www.openidenabled.com/resources/php-fetch-test'; $expected_url = $fetch_url . '.txt'; $result = $fetcher->get($fetch_url); |