Move proxy code inside if (->connected)

This commit is contained in:
Richard van den Berg 2015-03-19 09:13:14 +01:00 committed by mark_story
parent 7704efdb28
commit 15c80f7c3d

View file

@ -169,26 +169,25 @@ class CakeSocket {
$this->connected = is_resource($this->connection);
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';
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");
fwrite($this->connection, implode("\r\n", $req) . "\r\n\r\n");
while (!feof($this->connection)) {
$s = rtrim(fgets($this->connection, 4096));
if (preg_match('/^$/', $s)) {
break;
while (!feof($this->connection)) {
$s = rtrim(fgets($this->connection, 4096));
if (preg_match('/^$/', $s)) {
break;
}
}
$this->enableCrypto('tls', 'client');
}
$this->enableCrypto('tls', 'client');
}
return $this->connected;
}