Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Yadis

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /openid/Services/Yadis/HTTPFetcher.php

Documentation is available at HTTPFetcher.php

  1. <?php
  2.  
  3. /**
  4.  * This module contains the HTTP fetcher interface
  5.  *
  6.  * PHP versions 4 and 5
  7.  *
  8.  * LICENSE: See the COPYING file included in this distribution.
  9.  *
  10.  * @package Yadis
  11.  * @author JanRain, Inc. <[email protected]>
  12.  * @copyright 2005 Janrain, Inc.
  13.  * @license http://www.gnu.org/copyleft/lesser.html LGPL
  14.  */
  15.  
  16.     function Services_Yadis_HTTPResponse($final_url null$status null,
  17.                                          $headers null$body null)
  18.     {
  19.         $this->final_url $final_url;
  20.         $this->status $status;
  21.         $this->headers $headers;
  22.         $this->body $body;
  23.     }
  24. }
  25.  
  26. /**
  27.  * This class is the interface for HTTP fetchers the Yadis library
  28.  * uses.  This interface is only important if you need to write a new
  29.  * fetcher for some reason.
  30.  *
  31.  * @access private
  32.  * @package Yadis
  33.  */
  34. class Services_Yadis_HTTPFetcher {
  35.  
  36.     var $timeout 20// timeout in seconds.
  37.  
  38.     
  39.     /**
  40.      * Return whether a URL should be allowed. Override this method to
  41.      * conform to your local policy.
  42.      *
  43.      * By default, will attempt to fetch any http or https URL.
  44.      */
  45.     function allowedURL($url)
  46.     {
  47.         return $this->URLHasAllowedScheme($url);
  48.     }
  49.  
  50.     /**
  51.      * Is this an http or https URL?
  52.      *
  53.      * @access private
  54.      */
  55.     function URLHasAllowedScheme($url)
  56.     {
  57.         return (bool)preg_match('/^https?:\/\//i'$url);
  58.     }
  59.  
  60.     /**
  61.      * @access private
  62.      */
  63.     function _findRedirect($headers)
  64.     {
  65.         foreach ($headers as $line{
  66.             if (strpos($line"Location: "=== 0{
  67.                 $parts explode(" "$line2);
  68.                 return $parts[1];
  69.             }
  70.         }
  71.         return null;
  72.     }
  73.  
  74.     /**
  75.      * Fetches the specified URL using optional extra headers and
  76.      * returns the server's response.
  77.      *
  78.      * @param string $url The URL to be fetched.
  79.      * @param array $extra_headers An array of header strings
  80.      *  (e.g. "Accept: text/html").
  81.      * @return mixed $result An array of ($code, $url, $headers,
  82.      *  $body) if the URL could be fetched; null if the URL does not
  83.      *  pass the URLHasAllowedScheme check or if the server's response
  84.      *  is malformed.
  85.      */
  86.     function get($url$headers)
  87.     {
  88.         trigger_error("not implemented"E_USER_ERROR);
  89.     }
  90. }
  91.  
  92. ?>

Documentation generated on Mon, 05 Mar 2007 21:07:09 +0000 by phpDocumentor 1.3.1