19 require_once 
"Auth/Yadis/HTTPFetcher.php";
 
   21 require_once 
"Auth/OpenID.php";
 
   37         $this->headers = array();
 
   46         array_push($this->headers, rtrim($header));
 
   47         return strlen($header);
 
   70             return in_array(
'https', $v[
'protocols']);
 
   71         } elseif (is_string($v)) {
 
   72             return preg_match(
'/OpenSSL/i', $v);
 
   78     function get($url, $extra_headers = null)
 
   89         while ($redir && ($off > 0)) {
 
   96                     "curl_init returned false; could not " .
 
   97                     "initialize for URL '%s'", $url);
 
  101             if (defined(
'CURLOPT_NOSIGNAL')) {
 
  102                 curl_setopt($c, CURLOPT_NOSIGNAL, 
true);
 
  111             curl_setopt($c, CURLOPT_WRITEFUNCTION,
 
  112                         array($this, 
"_writeData"));
 
  113             curl_setopt($c, CURLOPT_HEADERFUNCTION,
 
  114                         array($this, 
"_writeHeader"));
 
  116             if ($extra_headers) {
 
  117                 curl_setopt($c, CURLOPT_HTTPHEADER, $extra_headers);
 
  120             $cv = curl_version();
 
  122               $curl_user_agent = 
'curl/'.$cv[
'version'];
 
  124               $curl_user_agent = $cv;
 
  126             curl_setopt($c, CURLOPT_USERAGENT,
 
  128             curl_setopt($c, CURLOPT_TIMEOUT, $off);
 
  129             curl_setopt($c, CURLOPT_URL, $url);
 
  131             if (defined(
'Auth_OpenID_VERIFY_HOST')) {
 
  132                 curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 
true);
 
  133                 curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
 
  137             $code = curl_getinfo($c, CURLINFO_HTTP_CODE);
 
  139             $headers = $this->headers;
 
  144                                  curl_errno($c), curl_error($c));
 
  148             if (in_array($code, array(301, 302, 303, 307))) {
 
  155                 if (defined(
'Auth_OpenID_VERIFY_HOST') &&
 
  160                 $new_headers = array();
 
  162                 foreach ($headers as $header) {
 
  163                     if (strpos($header, 
': ')) {
 
  164                         list($name, $value) = explode(
': ', $header, 2);
 
  165                         $new_headers[$name] = $value;
 
  170                     "Successfully fetched '%s': GET response code %s",
 
  174                                                     $new_headers, $body);
 
  177             $off = $stop - time();
 
  183     function post($url, $body, $extra_headers = null)
 
  193         if (defined(
'CURLOPT_NOSIGNAL')) {
 
  194             curl_setopt($c, CURLOPT_NOSIGNAL, 
true);
 
  197         curl_setopt($c, CURLOPT_POST, 
true);
 
  198         curl_setopt($c, CURLOPT_POSTFIELDS, $body);
 
  199         curl_setopt($c, CURLOPT_TIMEOUT, $this->timeout);
 
  200         curl_setopt($c, CURLOPT_URL, $url);
 
  201         curl_setopt($c, CURLOPT_WRITEFUNCTION,
 
  202                     array($this, 
"_writeData"));
 
  204         if (defined(
'Auth_OpenID_VERIFY_HOST')) {
 
  205             curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 
true);
 
  206             curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
 
  211         $code = curl_getinfo($c, CURLINFO_HTTP_CODE);
 
  216                              curl_errno($c), curl_error($c));
 
  220         if (defined(
'Auth_OpenID_VERIFY_HOST') && $this->
isHTTPS($url)) {
 
  228         $new_headers = $extra_headers;
 
  230         foreach ($this->headers as $header) {
 
  231             if (strpos($header, 
': ')) {
 
  232                 list($name, $value) = explode(
': ', $header, 2);
 
  233                 $new_headers[$name] = $value;
 
  242                                            $new_headers, $body);