/** * Abre a requisição. * * @param \Moip\Http\HTTPConnection $httpConnection Conexão HTTP relacionada com essa requisição * * @see \Moip\Http\HTTPRequest::open() */ public function open(HTTPConnection $httpConnection) { if (function_exists('curl_init')) { $this->close(); $curl = curl_init(); if (is_resource($curl)) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // FIXME curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLINFO_HEADER_OUT, true); if (($timeout = $httpConnection->getTimeout()) != null) { curl_setopt($curl, CURLOPT_TIMEOUT, $timeout); } if (($connectionTimeout = $httpConnection->getConnectionTimeout()) != null) { curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $connectionTimeout); } $headers = array(); foreach ($this->requestHeader as $header) { $headers[] = sprintf('%s: %s', $header['name'], $header['value']); } curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $this->curlResource = $curl; $this->httpConnection = $httpConnection; $this->openned = true; } else { throw new RuntimeException('cURL failed to start'); } } else { throw new RuntimeException('cURL not found.'); } }