private function open() { try { $context = stream_context_create(array('http' => array('timeout' => $this->timeout, 'header' => "X-Fw-Transfer: soap\r\n"))); $parametros = array(); $parametros['location'] = $this->url; $parametros['uri'] = dirname($this->url); $parametros['trace'] = 1; $parametros['encoding'] = 'iso-8859-1'; $parametros['exceptions'] = true; $parametros['connection_timeout'] = $this->timeout; $parametros['stream_context'] = $context; if ($this->isProxy()) { $parametros['proxy_host'] = $this->proxyHost; $parametros['proxy_port'] = $this->proxyPort; if ($this->isAuthProxy()) { $parametros['proxy_login'] = $this->proxyLogin; $parametros['proxy_password'] = $this->proxyPass; } } //$parametros['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP; // manda compactado // abre uma requisicao para o arquivo, que vai criar as funcoes // para serem utilizadas local $this->soapClient = new \SoapClient(null, $parametros); } catch (\Exception $e) { throw TransferException::couldNotConnect($this->url . ($this->isProxy() ? ' (usando proxy)' : ''), $e->getMessage()); } }
private function open() { $errno = $errstr = null; if ($this->isProxy()) { $this->sck = fsockopen($this->proxyHost, $this->proxyPort, $errno, $errstr, $this->timeout); } else { $this->sck = fsockopen($this->host, 80, $errno, $errstr, $this->timeout); } if (!$this->sck) { throw TransferException::couldNotConnect($this->url . ($this->isProxy() ? ' (usando proxy)' : ''), "[{$errno}] {$errstr}"); } }
private function open() { $this->curl = curl_init(); if (!$this->curl) { throw TransferException::couldNotConnect($this->url . ($this->isProxy() ? ' (usando proxy)' : ''), 'Desconhecido'); } curl_setopt($this->curl, CURLOPT_FAILONERROR, true); // erro >= 400 dá falha curl_setopt($this->curl, CURLOPT_FRESH_CONNECT, true); // nunca usar cache curl_setopt($this->curl, CURLOPT_HEADER, true); // para os readers de response virem junto com o body /*curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('X-FW-Token: ' . $this->getToken()));*/ curl_setopt($this->curl, CURLOPT_HTTPHEADER, array('X-FW-Transfer: curl')); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); // retorna response em string em vez de output if ($this->isProxy()) { curl_setopt($this->curl, CURLOPT_PROXY, $this->proxyHost); curl_setopt($this->curl, CURLOPT_PROXYPORT, $this->proxyPort); switch ($this->proxyProtocol) { case 'http': curl_setopt($this->curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); break; case 'socks4': curl_setopt($this->curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4); break; case 'socks5': curl_setopt($this->curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); break; } if ($this->isAuthProxy()) { curl_setopt($this->curl, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); curl_setopt($this->curl, CURLOPT_PROXYUSERPWD, "{$this->proxyLogin}:{$this->proxyPass}"); } } }