mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Move proxy code inside if (->connected)
This commit is contained in:
parent
7704efdb28
commit
15c80f7c3d
1 changed files with 13 additions and 14 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue