|
| connect ($host, $port=80, $secure=false) |
|
| write ( $method, $uri, $http_ver='1.1', $headers=array(), $body='') |
|
| close () |
|
| __destruct () |
|
| __construct () |
|
| setConfig ($config=array()) |
|
| getConfig () |
|
| setStreamContext ($context) |
|
| getStreamContext () |
|
| connect ($host, $port=80, $secure=false) |
|
| write ($method, $uri, $http_ver='1.1', $headers=array(), $body='') |
|
| read () |
|
| close () |
|
| setOutputStream ($stream) |
|
| __destruct () |
|
Definition at line 52 of file Proxy.php.
◆ __destruct()
Destructor: make sure the socket is disconnected
Definition at line 335 of file Proxy.php.
◆ close()
◆ connect()
connect |
( |
|
$host, |
|
|
|
$port = 80 , |
|
|
|
$secure = false |
|
) |
| |
Connect to the remote server
Will try to connect to the proxy server. If no proxy was set, will fall back to the target server (behave like regular Socket adapter)
- Parameters
-
string | $host | |
int | $port | |
boolean | $secure | |
Implements Zend_Http_Client_Adapter_Interface.
Definition at line 96 of file Proxy.php.
99 if (!$this->config[
'proxy_host']) {
100 return parent::connect($host, $port, $secure);
105 $this->config[
'sslusecontext'] =
true;
109 return parent::connect(
110 $this->config[
'proxy_host'],
111 $this->config[
'proxy_port'],
◆ connectHandshake()
connectHandshake |
( |
|
$host, |
|
|
|
$port = 443 , |
|
|
|
$http_ver = '1.1' , |
|
|
array & |
$headers = array() |
|
) |
| |
|
protected |
Preform handshaking with HTTPS proxy using CONNECT method
- Parameters
-
string | $host | |
integer | $port | |
string | $http_ver | |
array | $headers | |
- Returns
- void
- Exceptions
-
Definition at line 242 of file Proxy.php.
246 $request =
"CONNECT $host:$port HTTP/$http_ver\r\n" .
247 "Host: " . $host .
"\r\n";
250 foreach ($headers as $k => $v) {
251 switch (strtolower(substr($v,0,strpos($v,
':')))) {
252 case 'proxy-authorization':
266 $this->connectHandshakeRequest =
$request;
270 #require_once 'Zend/Http/Client/Adapter/Exception.php'; 272 'Error writing request to proxy server' 279 while ($line = @fgets($this->socket)) {
280 $gotStatus = $gotStatus || (strpos($line,
'HTTP') !==
false);
291 #require_once 'Zend/Http/Client/Adapter/Exception.php'; 293 'Unable to connect to HTTPS proxy. Server response: ' .
$response 301 STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
305 foreach($modes as
$mode) {
306 $success = stream_socket_enable_crypto($this->socket,
true,
$mode);
313 #require_once 'Zend/Http/Client/Adapter/Exception.php'; 315 'Unable to connect to HTTPS server through proxy: could not ' 316 .
'negotiate secure connection.'
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
static extractCode($response_str)
◆ write()
write |
( |
|
$method, |
|
|
|
$uri, |
|
|
|
$http_ver = '1.1' , |
|
|
|
$headers = array() , |
|
|
|
$body = '' |
|
) |
| |
Send request to the proxy server
- Parameters
-
string | $method | |
Zend_Uri_Http | $uri | |
string | $http_ver | |
array | $headers | |
string | $body | |
- Returns
- string Request as string
- Exceptions
-
Implements Zend_Http_Client_Adapter_Interface.
Definition at line 127 of file Proxy.php.
132 if (!$this->config[
'proxy_host']) {
133 return parent::write(
$method, $uri, $http_ver, $headers, $body);
137 if (!$this->socket) {
138 #require_once 'Zend/Http/Client/Adapter/Exception.php'; 140 'Trying to write but we are not connected' 144 $host = $this->config[
'proxy_host'];
145 $port = $this->config[
'proxy_port'];
147 if ($this->connected_to[0] !=
"tcp://$host" 148 || $this->connected_to[1] != $port
150 #require_once 'Zend/Http/Client/Adapter/Exception.php'; 152 'Trying to write but we are connected to the wrong proxy server' 157 if ($this->config[
'proxy_user']) {
159 $hasProxyAuthHeader =
false;
160 foreach ($headers as $k => $v) {
161 if ((
string) $k ==
'proxy-authorization' 162 || preg_match(
"/^proxy-authorization:/i", $v)
164 $hasProxyAuthHeader =
true;
168 if (!$hasProxyAuthHeader) {
169 $headers[] =
'Proxy-authorization: ' 171 $this->config[
'proxy_user'],
172 $this->config[
'proxy_pass'], $this->config[
'proxy_auth']
180 $uri->getHost(), $uri->getPort(), $http_ver, $headers
182 $this->negotiated =
true;
189 if ($this->negotiated) {
190 $path = $uri->getPath();
191 if ($uri->getQuery()) {
192 $path .=
'?' . $uri->getQuery();
194 $request =
"$method $path HTTP/$http_ver\r\n";
196 $request =
"$method $uri HTTP/$http_ver\r\n";
200 foreach ($headers as $k => $v) {
201 if (is_string($k)) $v =
"$k: $v";
214 #require_once 'Zend/Http/Client/Adapter/Exception.php'; 216 'Error writing request to proxy server' 221 if(stream_copy_to_stream($body, $this->socket) == 0) {
222 #require_once 'Zend/Http/Client/Adapter/Exception.php'; 224 'Error writing request to server'
connectHandshake( $host, $port=443, $http_ver='1.1', array &$headers=array())
static encodeAuthHeader($user, $password, $type=self::AUTH_BASIC)
◆ $config
Initial value:= array(
'ssltransport' => 'ssl',
'sslcert' => null,
'sslpassphrase' => null,
'sslusecontext' => false,
'proxy_host' => '',
'proxy_port' => 8080,
'proxy_user' => '',
'proxy_pass' => '',
'persistent' => false,
)
Definition at line 59 of file Proxy.php.
◆ $connectHandshakeRequest
◆ $negotiated
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Http/Client/Adapter/Proxy.php