ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Auth_Yadis_HTTPFetcher Class Reference
+ Inheritance diagram for Auth_Yadis_HTTPFetcher:
+ Collaboration diagram for Auth_Yadis_HTTPFetcher:

Public Member Functions

 canFetchURL ($url)
 Return whether a URL can be fetched. More...
 
 allowedURL ($url)
 Return whether a URL should be allowed. More...
 
 supportsSSL ()
 Does this fetcher implementation (and runtime) support fetching HTTPS URLs? May inspect the runtime environment. More...
 
 isHTTPS ($url)
 Is this an https URL? More...
 
 URLHasAllowedScheme ($url)
 Is this an http or https URL? More...
 
 _findRedirect ($headers, $url)
 @access private More...
 
 get ($url, $headers=null)
 Fetches the specified URL using optional extra headers and returns the server's response. More...
 

Data Fields

 $timeout = 20
 

Detailed Description

Definition at line 43 of file HTTPFetcher.php.

Member Function Documentation

◆ _findRedirect()

Auth_Yadis_HTTPFetcher::_findRedirect (   $headers,
  $url 
)

@access private

Definition at line 117 of file HTTPFetcher.php.

119 {
120 foreach ($headers as $line) {
121 if (strpos(strtolower($line), "location: ") === 0) {
122 $parts = explode(" ", $line, 2);
123 $loc = $parts[1];
124 $ppos = strpos($loc, "://");
125 if ($ppos === false || $ppos > strpos($loc, "/")) {
126 /* no host; add it */
127 $hpos = strpos($url, "://");
128 $prt = substr($url, 0, $hpos+3);
129 $url = substr($url, $hpos+3);
130 if (substr($loc, 0, 1) == "/") {
131 /* absolute path */
132 $fspos = strpos($url, "/");
133 if ($fspos) $loc = $prt.substr($url, 0, $fspos).$loc;
134 else $loc = $prt.$url.$loc;
135 } else {
136 /* relative path */
137 $pp = $prt;
138 while (1) {
139 $xpos = strpos($url, "/");
140 if ($xpos === false) break;
141 $apos = strpos($url, "?");
142 if ($apos !== false && $apos < $xpos) break;
143 $apos = strpos($url, "&");
144 if ($apos !== false && $apos < $xpos) break;
145 $pp .= substr($url, 0, $xpos+1);
146 $url = substr($url, $xpos+1);
147 }
148 $loc = $pp.$loc;
149 }
150 }
151 return $loc;
152 }
153 }
154 return null;
$url
Definition: shib_logout.php:72

Referenced by Auth_Yadis_ParanoidHTTPFetcher\get(), and Auth_Yadis_PlainHTTPFetcher\get().

+ Here is the caller graph for this function:

◆ allowedURL()

Auth_Yadis_HTTPFetcher::allowedURL (   $url)

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.

Definition at line 77 of file HTTPFetcher.php.

79 {
80 return $this->URLHasAllowedScheme($url);
URLHasAllowedScheme($url)
Is this an http or https URL?

Referenced by Auth_Yadis_ParanoidHTTPFetcher\get().

+ Here is the caller graph for this function:

◆ canFetchURL()

Auth_Yadis_HTTPFetcher::canFetchURL (   $url)

Return whether a URL can be fetched.

Returns false if the URL scheme is not allowed or is not supported by this fetcher implementation; returns true otherwise.

Returns
bool

Definition at line 54 of file HTTPFetcher.php.

56 {
57 if ($this->isHTTPS($url) && !$this->supportsSSL()) {
58 Auth_OpenID::log("HTTPS URL unsupported fetching %s",
59 $url);
60 return false;
61 }
62
63 if (!$this->allowedURL($url)) {
64 Auth_OpenID::log("URL fetching not allowed for '%s'",
65 $url);
66 return false;
67 }
68
69 return true;
static log($format_string)
Wrap PHP's standard error_log functionality.
Definition: OpenID.php:525
supportsSSL()
Does this fetcher implementation (and runtime) support fetching HTTPS URLs? May inspect the runtime e...
Definition: HTTPFetcher.php:89
allowedURL($url)
Return whether a URL should be allowed.
Definition: HTTPFetcher.php:77
isHTTPS($url)
Is this an https URL?
Definition: HTTPFetcher.php:99

Referenced by Auth_Yadis_ParanoidHTTPFetcher\get(), Auth_Yadis_PlainHTTPFetcher\get(), Auth_Yadis_ParanoidHTTPFetcher\post(), and Auth_Yadis_PlainHTTPFetcher\post().

+ Here is the caller graph for this function:

◆ get()

Auth_Yadis_HTTPFetcher::get (   $url,
  $headers = null 
)

Fetches the specified URL using optional extra headers and returns the server's response.

Parameters
string$urlThe URL to be fetched.
array$extra_headersAn array of header strings (e.g. "Accept: text/html").
Returns
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.

Reimplemented in Auth_Yadis_ParanoidHTTPFetcher, and Auth_Yadis_PlainHTTPFetcher.

Definition at line 168 of file HTTPFetcher.php.

170 {
171 trigger_error("not implemented", E_USER_ERROR);

◆ isHTTPS()

Auth_Yadis_HTTPFetcher::isHTTPS (   $url)

Is this an https URL?

@access private

Definition at line 99 of file HTTPFetcher.php.

101 {
102 return (bool)preg_match('/^https:\/\//i', $url);

Referenced by Auth_Yadis_ParanoidHTTPFetcher\get(), and Auth_Yadis_ParanoidHTTPFetcher\post().

+ Here is the caller graph for this function:

◆ supportsSSL()

Auth_Yadis_HTTPFetcher::supportsSSL ( )

Does this fetcher implementation (and runtime) support fetching HTTPS URLs? May inspect the runtime environment.

Returns
bool $support True if this fetcher supports HTTPS fetching; false if not.

Reimplemented in Auth_Yadis_ParanoidHTTPFetcher, and Auth_Yadis_PlainHTTPFetcher.

Definition at line 89 of file HTTPFetcher.php.

91 {
92 trigger_error("not implemented", E_USER_ERROR);

◆ URLHasAllowedScheme()

Auth_Yadis_HTTPFetcher::URLHasAllowedScheme (   $url)

Is this an http or https URL?

@access private

Definition at line 109 of file HTTPFetcher.php.

111 {
112 return (bool)preg_match('/^https?:\/\//i', $url);

Field Documentation

◆ $timeout

Auth_Yadis_HTTPFetcher::$timeout = 20

The documentation for this class was generated from the following file: