Esempio n. 1
0
 /**
  * Sets the CURLOPT options for the current request
  * @param string $url
  */
 protected function setRequestOptions($requestResource, $method, $url, $post = array())
 {
     $this->setRequestMethod($method);
     $this->setOption('url', $url);
     if ($post && is_array($post)) {
         $post = http_build_query($post, '', '&');
         $this->setOption('postfields', $post);
     }
     // Prepend headers in response
     $this->setOption('header', TRUE);
     // this makes me literally cry sometimes
     // we shouldn't trust to all certificates but we have to!
     if ($this->getOption('ssl_verifypeer') === NULL) {
         $this->setOption('ssl_verifypeer', FALSE);
     }
     // fix:Sairon http://forum.nette.org/cs/profile.php?id=1844 thx
     if ($this->followRedirects === NULL && !Tools::iniFlag('safe_mode') && ini_get('open_basedir') == "") {
         $this->followRedirects = TRUE;
     }
     // Set all cURL options
     foreach ($this->Options as $option => $value) {
         if ($option == "FOLLOWLOCATION" && (Tools::iniFlag('safe_mode') || ini_get('open_basedir') != "")) {
             continue;
         }
         curl_setopt($requestResource, constant('CURLOPT_' . $option), $value);
     }
 }