Skip to content

Commit

Permalink
updates for Swoole 4.5.11
Browse files Browse the repository at this point in the history
  • Loading branch information
deminy committed Jan 10, 2021
1 parent 11d77b6 commit e0b82d8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
6 changes: 3 additions & 3 deletions output/swoole/constants.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

define('SWOOLE_VERSION', '4.5.10');
define('SWOOLE_VERSION_ID', 40510);
define('SWOOLE_VERSION', '4.5.11');
define('SWOOLE_VERSION_ID', 40511);
define('SWOOLE_MAJOR_VERSION', 4);
define('SWOOLE_MINOR_VERSION', 5);
define('SWOOLE_RELEASE_VERSION', 10);
define('SWOOLE_RELEASE_VERSION', 11);
define('SWOOLE_EXTRA_VERSION', '');
define('SWOOLE_DEBUG', '');
define('SWOOLE_HAVE_COMPRESSION', '1');
Expand Down
41 changes: 27 additions & 14 deletions output/swoole_library/src/core/Curl/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private function setOption(int $opt, $value): bool
case CURLOPT_FILE:
case CURLOPT_INFILE:
if (!is_resource($value)) {
trigger_error(E_USER_WARNING, 'swoole_curl_setopt(): supplied argument is not a valid File-Handle resource');
trigger_error('swoole_curl_setopt(): supplied argument is not a valid File-Handle resource', E_USER_WARNING);
return false;
}
break;
Expand Down Expand Up @@ -434,7 +434,7 @@ private function setOption(int $opt, $value): bool
* Ignore options
*/
case CURLOPT_VERBOSE:
// trigger_error(E_USER_WARNING, 'swoole_curl_setopt(): CURLOPT_VERBOSE is not supported');
// trigger_error('swoole_curl_setopt(): CURLOPT_VERBOSE is not supported', E_USER_WARNING);
case CURLOPT_SSLVERSION:
case CURLOPT_NOSIGNAL:
case CURLOPT_FRESH_CONNECT:
Expand Down Expand Up @@ -653,9 +653,20 @@ private function execute()
* Http Proxy
*/
if ($this->proxy) {
$proxy = explode(':', $this->proxy);
$proxyPort = $proxy[1] ?? $this->proxyPort;
$proxy = $proxy[0];
$parse = parse_url($this->proxy);
$proxy = $parse['host'] ?? $parse['path'];
$proxyPort = $parse['port'] ?? $this->proxyPort;
$proxyUsername = $parse['user'] ?? $this->proxyUsername;
$proxyPassword = $parse['pass'] ?? $this->proxyPassword;
$proxyType = $parse['scheme'] ?? $this->proxyType;
if (is_string($proxyType)) {
if ($proxyType === 'socks5') {
$proxyType = CURLPROXY_SOCKS5;
} else {
$proxyType = CURLPROXY_HTTP;
}
}

if (!filter_var($proxy, FILTER_VALIDATE_IP)) {
$ip = Swoole\Coroutine::gethostbyname($proxy, AF_INET, $this->clientOptions['connect_timeout'] ?? -1);
if (!$ip) {
Expand All @@ -664,25 +675,25 @@ private function execute()
}
$this->proxy = $proxy = $ip;
}
switch ($this->proxyType) {
switch ($proxyType) {
case CURLPROXY_HTTP:
$proxyOptions = [
'http_proxy_host' => $proxy,
'http_proxy_port' => $proxyPort,
'http_proxy_username' => $this->proxyUsername,
'http_proxy_password' => $this->proxyPassword,
'http_proxy_username' => $proxyUsername,
'http_proxy_password' => $proxyPassword,
];
break;
case CURLPROXY_SOCKS5:
$proxyOptions = [
'socks5_host' => $proxy,
'socks5_port' => $proxyPort,
'socks5_username' => $this->proxyUsername,
'socks5_password' => $this->proxyPassword,
'socks5_username' => $proxyUsername,
'socks5_password' => $proxyPassword,
];
break;
default:
throw new CurlException("Unexpected proxy type [{$this->proxyType}]");
throw new CurlException("Unexpected proxy type [{$proxyType}]");
}
}
/*
Expand Down Expand Up @@ -919,9 +930,11 @@ private function getRedirectUrl(string $location): array
}
$redirectUri['path'] = $path . $location;
}
foreach ($uri as $k => $v) {
if (!in_array($k, ['path', 'query'])) {
$redirectUri[$k] = $v;
if (is_array($uri)) {
foreach ($uri as $k => $v) {
if (!in_array($k, ['path', 'query'])) {
$redirectUri[$k] = $v;
}
}
}
}
Expand Down

0 comments on commit e0b82d8

Please sign in to comment.