示例#1
0
 /**
  * Establishes a tunnel to a secure remote server via HTTP CONNECT request
  *
  * This method will fail if 'ssl_verify_peer' is enabled. Probably because PHP
  * sees that we are connected to a proxy server (duh!) rather than the server
  * that presents its certificate.
  *
  * @link     http://tools.ietf.org/html/rfc2817#section-5.2
  * @throws   HTTP_Request2_Exception
  */
 protected function establishTunnel()
 {
     $donor = new self();
     $connect = new HTTP_Request2($this->request->getUrl(), HTTP_Request2::METHOD_CONNECT, array_merge($this->request->getConfig(), array('adapter' => $donor)));
     $response = $connect->send();
     // Need any successful (2XX) response
     if (200 > $response->getStatus() || 300 <= $response->getStatus()) {
         throw new HTTP_Request2_ConnectionException('Failed to connect via HTTPS proxy. Proxy response: ' . $response->getStatus() . ' ' . $response->getReasonPhrase());
     }
     $this->socket = $donor->socket;
     $this->socket->enableCrypto();
 }