diff options
author | lisps <stummp@loewen.de> | 2014-02-17 23:15:36 +0100 |
---|---|---|
committer | lisps <stummp@loewen.de> | 2014-02-17 23:15:36 +0100 |
commit | d90a79c0ee1837353622e4b2abb0753ca09dffd2 (patch) | |
tree | 554da8dc13606efc2bc1ea7fe3697a5ff87d02e5 /inc/HTTPClient.php | |
parent | f2643d9ff318af1d2fbb6249e929212381959247 (diff) | |
parent | a83975113c7725a13144b3e65bfb58c8447d37d7 (diff) | |
download | rpg-d90a79c0ee1837353622e4b2abb0753ca09dffd2.tar.gz rpg-d90a79c0ee1837353622e4b2abb0753ca09dffd2.tar.bz2 |
Merge remote-tracking branch 'origin/diff_navigation' into revisions
Conflicts:
inc/parser/xhtml.php
Diffstat (limited to 'inc/HTTPClient.php')
-rw-r--r-- | inc/HTTPClient.php | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 96954fb47..de3a16830 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -254,7 +254,13 @@ class HTTPClient { } // add SSL stream prefix if needed - needs SSL support in PHP - if($port == 443 || $this->proxy_ssl) $server = 'ssl://'.$server; + if($port == 443 || $this->proxy_ssl) { + if(!in_array('ssl', stream_get_transports())) { + $this->status = -200; + $this->error = 'This PHP version does not support SSL - cannot connect to server'; + } + $server = 'ssl://'.$server; + } // prepare headers $headers = $this->headers; @@ -304,11 +310,18 @@ class HTTPClient { } // try establish a CONNECT tunnel for SSL - if($this->_ssltunnel($socket, $request_url)){ - // no keep alive for tunnels - $this->keep_alive = false; - // tunnel is authed already - if(isset($headers['Proxy-Authentication'])) unset($headers['Proxy-Authentication']); + try { + if($this->_ssltunnel($socket, $request_url)){ + // no keep alive for tunnels + $this->keep_alive = false; + // tunnel is authed already + if(isset($headers['Proxy-Authentication'])) unset($headers['Proxy-Authentication']); + } + } catch (HTTPClientException $e) { + $this->status = $e->getCode(); + $this->error = $e->getMessage(); + fclose($socket); + return false; } // keep alive? @@ -363,7 +376,7 @@ class HTTPClient { // get Status if (!preg_match('/^HTTP\/(\d\.\d)\s*(\d+).*?\n/', $r_headers, $m)) - throw new HTTPClientException('Server returned bad answer'); + throw new HTTPClientException('Server returned bad answer '.$r_headers); $this->status = $m[2]; @@ -526,6 +539,7 @@ class HTTPClient { * * @param resource &$socket * @param string &$requesturl + * @throws HTTPClientException when a tunnel is needed but could not be established * @return bool true if a tunnel was established */ function _ssltunnel(&$socket, &$requesturl){ @@ -559,7 +573,8 @@ class HTTPClient { return true; } } - return false; + + throw new HTTPClientException('Failed to establish secure proxy connection', -150); } /** |