Addapted quick hack from issue #2057 for 2.6.3

This commit is contained in:
Richard van den Berg 2015-03-17 13:40:36 +01:00 committed by mark_story
parent 07de23a692
commit 54a3f8724b
2 changed files with 30 additions and 1 deletions

View file

@ -130,7 +130,7 @@ class CakeSocket {
}
$scheme = null;
if (!empty($this->config['protocol']) && strpos($this->config['host'], '://') === false) {
if (!empty($this->config['protocol']) && strpos($this->config['host'], '://') === false && empty($this->config['proxy'])) {
$scheme = $this->config['protocol'] . '://';
}
@ -170,6 +170,34 @@ class CakeSocket {
if ($this->connected) {
stream_set_timeout($this->connection, $this->config['timeout']);
}
if (!empty($this->config['request']) && $this->config['request']['uri']['scheme'] == 'https' && !empty($this->config['proxy'])) {
$req = array();
$req[] = 'CONNECT '. $this->config['request']['uri']['host'] . ':' . $this->config['request']['uri']['port'] . ' HTTP/1.1';
$req[] = 'Host: ' . $this->config['host'];
$req[] = 'User-Agent: php proxy';
fwrite($this->connection, implode("\r\n", $req)."\r\n\r\n");
while(true) {
$s = rtrim(fgets($this->connection, 4096));
if(preg_match('/^$/', $s)) {
break;
}
}
$modes = array(STREAM_CRYPTO_METHOD_TLS_CLIENT,
STREAM_CRYPTO_METHOD_SSLv3_CLIENT,
STREAM_CRYPTO_METHOD_SSLv23_CLIENT,
STREAM_CRYPTO_METHOD_SSLv2_CLIENT);
$success = false;
foreach($modes as $mode) {
$success = stream_socket_enable_crypto($this->connection, true, $mode);
if ($success) break;
}
}
return $this->connected;
}

View file

@ -652,6 +652,7 @@ class HttpSocket extends CakeSocket {
}
$this->config['host'] = $this->_proxy['host'];
$this->config['port'] = $this->_proxy['port'];
$this->config['proxy'] = true;
if (empty($this->_proxy['method']) || !isset($this->_proxy['user'], $this->_proxy['pass'])) {
return;