Öffentliche Methoden | |
Auth_Yadis_ParanoidHTTPFetcher () | |
reset () | |
_writeHeader ($ch, $header) | |
_writeData ($ch, $data) | |
supportsSSL () | |
get ($url, $extra_headers=null) | |
post ($url, $body, $extra_headers=null) |
Definiert in Zeile 29 der Datei ParanoidHTTPFetcher.php.
_writeData | ( | $ | ch, | |
$ | data | |||
) |
private
Definiert in Zeile 53 der Datei ParanoidHTTPFetcher.php.
00054 { 00055 if (strlen($this->data) > 1024*Auth_OpenID_FETCHER_MAX_RESPONSE_KB) { 00056 return 0; 00057 } else { 00058 $this->data .= $data; 00059 return strlen($data); 00060 } 00061 }
_writeHeader | ( | $ | ch, | |
$ | header | |||
) |
get | ( | $ | url, | |
$ | headers = null | |||
) |
Fetches the specified URL using optional extra headers and returns the server's response.
string | $url The URL to be fetched. | |
array | $extra_headers An array of header strings (e.g. "Accept: text/html"). |
Erneute Implementation von Auth_Yadis_HTTPFetcher.
Definiert in Zeile 78 der Datei ParanoidHTTPFetcher.php.
00079 { 00080 if (!$this->canFetchURL($url)) { 00081 return null; 00082 } 00083 00084 $stop = time() + $this->timeout; 00085 $off = $this->timeout; 00086 00087 $redir = true; 00088 00089 while ($redir && ($off > 0)) { 00090 $this->reset(); 00091 00092 $c = curl_init(); 00093 00094 if ($c === false) { 00095 Auth_OpenID::log( 00096 "curl_init returned false; could not " . 00097 "initialize for URL '%s'", $url); 00098 return null; 00099 } 00100 00101 if (defined('CURLOPT_NOSIGNAL')) { 00102 curl_setopt($c, CURLOPT_NOSIGNAL, true); 00103 } 00104 00105 if (!$this->allowedURL($url)) { 00106 Auth_OpenID::log("Fetching URL not allowed: %s", 00107 $url); 00108 return null; 00109 } 00110 00111 curl_setopt($c, CURLOPT_WRITEFUNCTION, 00112 array(&$this, "_writeData")); 00113 curl_setopt($c, CURLOPT_HEADERFUNCTION, 00114 array(&$this, "_writeHeader")); 00115 00116 if ($extra_headers) { 00117 curl_setopt($c, CURLOPT_HTTPHEADER, $extra_headers); 00118 } 00119 00120 $cv = curl_version(); 00121 if(is_array($cv)) { 00122 $curl_user_agent = 'curl/'.$cv['version']; 00123 } else { 00124 $curl_user_agent = $cv; 00125 } 00126 curl_setopt($c, CURLOPT_USERAGENT, 00127 Auth_OpenID_USER_AGENT.' '.$curl_user_agent); 00128 curl_setopt($c, CURLOPT_TIMEOUT, $off); 00129 curl_setopt($c, CURLOPT_URL, $url); 00130 00131 curl_exec($c); 00132 00133 $code = curl_getinfo($c, CURLINFO_HTTP_CODE); 00134 $body = $this->data; 00135 $headers = $this->headers; 00136 00137 if (!$code) { 00138 Auth_OpenID::log("Got no response code when fetching %s", $url); 00139 Auth_OpenID::log("CURL error (%s): %s", 00140 curl_errno($c), curl_error($c)); 00141 return null; 00142 } 00143 00144 if (in_array($code, array(301, 302, 303, 307))) { 00145 $url = $this->_findRedirect($headers); 00146 $redir = true; 00147 } else { 00148 $redir = false; 00149 curl_close($c); 00150 00151 $new_headers = array(); 00152 00153 foreach ($headers as $header) { 00154 if (strpos($header, ': ')) { 00155 list($name, $value) = explode(': ', $header, 2); 00156 $new_headers[$name] = $value; 00157 } 00158 } 00159 00160 Auth_OpenID::log( 00161 "Successfully fetched '%s': GET response code %s", 00162 $url, $code); 00163 00164 return new Auth_Yadis_HTTPResponse($url, $code, 00165 $new_headers, $body); 00166 } 00167 00168 $off = $stop - time(); 00169 } 00170 00171 return null; 00172 }
post | ( | $ | url, | |
$ | body, | |||
$ | extra_headers = null | |||
) |
Definiert in Zeile 174 der Datei ParanoidHTTPFetcher.php.
00175 { 00176 if (!$this->canFetchURL($url)) { 00177 return null; 00178 } 00179 00180 $this->reset(); 00181 00182 $c = curl_init(); 00183 00184 if (defined('CURLOPT_NOSIGNAL')) { 00185 curl_setopt($c, CURLOPT_NOSIGNAL, true); 00186 } 00187 00188 curl_setopt($c, CURLOPT_POST, true); 00189 curl_setopt($c, CURLOPT_POSTFIELDS, $body); 00190 curl_setopt($c, CURLOPT_TIMEOUT, $this->timeout); 00191 curl_setopt($c, CURLOPT_URL, $url); 00192 curl_setopt($c, CURLOPT_WRITEFUNCTION, 00193 array(&$this, "_writeData")); 00194 00195 curl_exec($c); 00196 00197 $code = curl_getinfo($c, CURLINFO_HTTP_CODE); 00198 00199 if (!$code) { 00200 Auth_OpenID::log("Got no response code when fetching %s", $url); 00201 return null; 00202 } 00203 00204 $body = $this->data; 00205 00206 curl_close($c); 00207 00208 $new_headers = $extra_headers; 00209 00210 foreach ($this->headers as $header) { 00211 if (strpos($header, ': ')) { 00212 list($name, $value) = explode(': ', $header, 2); 00213 $new_headers[$name] = $value; 00214 } 00215 00216 } 00217 00218 Auth_OpenID::log("Successfully fetched '%s': POST response code %s", 00219 $url, $code); 00220 00221 return new Auth_Yadis_HTTPResponse($url, $code, 00222 $new_headers, $body); 00223 }
reset | ( | ) |
supportsSSL | ( | ) |
Does this fetcher support SSL URLs?
Erneute Implementation von Auth_Yadis_HTTPFetcher.
Definiert in Zeile 66 der Datei ParanoidHTTPFetcher.php.
00067 { 00068 $v = curl_version(); 00069 if(is_array($v)) { 00070 return in_array('https', $v['protocols']); 00071 } elseif (is_string($v)) { 00072 return preg_match('/OpenSSL/i', $v); 00073 } else { 00074 return 0; 00075 } 00076 }
Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved. MyOOS [Shopsystem] is Free Software released under the GNU/GPL License. Webmaster: info@r23.de (Impressum) |
|