Skip to content

Commit 835373a

Browse files
committed
Proxy support fixed #53
1 parent 2b0e812 commit 835373a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Diff for: src/Connection/Protocols/Protocol.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ public function getProxy() {
145145

146146
/**
147147
* Prepare socket options
148+
* @var string $transport
148149
*
149150
* @return array
150151
*/
151-
private function defaultSocketOptions() {
152+
private function defaultSocketOptions($transport) {
152153
$options = [];
153154
if ($this->encryption != false) {
154155
$options["ssl"] = [
@@ -158,13 +159,13 @@ private function defaultSocketOptions() {
158159
}
159160

160161
if ($this->proxy["socket"] != null) {
161-
$options["proxy"] = $this->proxy["socket"];
162-
$options["request_fulluri"] = $this->proxy["request_fulluri"];
162+
$options[$transport]["proxy"] = $this->proxy["socket"];
163+
$options[$transport]["request_fulluri"] = $this->proxy["request_fulluri"];
163164

164165
if ($this->proxy["username"] != null) {
165166
$auth = base64_encode($this->proxy["username"].':'.$this->proxy["password"]);
166167

167-
$options["header"] = [
168+
$options[$transport]["header"] = [
168169
"Proxy-Authorization: Basic $auth"
169170
];
170171
}
@@ -188,7 +189,7 @@ protected function createStream($transport, $host, $port, $timeout) {
188189
$socket = "$transport://$host:$port";
189190
$stream = stream_socket_client($socket, $errno, $errstr, $timeout,
190191
STREAM_CLIENT_CONNECT,
191-
stream_context_create($this->defaultSocketOptions())
192+
stream_context_create($this->defaultSocketOptions($transport))
192193
);
193194

194195
if (!$stream) {

0 commit comments

Comments
 (0)