mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 19:42:15 +09:00
Move proxy setting to HTTP::_createClient()
This commit is contained in:
parent
7d88e532c9
commit
32ffc94dee
1 changed files with 14 additions and 11 deletions
|
|
@ -210,11 +210,23 @@ class HTTP
|
||||||
{
|
{
|
||||||
if (!self::$_client)
|
if (!self::$_client)
|
||||||
{
|
{
|
||||||
self::$_client = new \GuzzleHttp\Client([
|
// Create default settings.
|
||||||
|
$settings = [
|
||||||
'http_errors' => false,
|
'http_errors' => false,
|
||||||
'timeout' => self::DEFAULT_TIMEOUT,
|
'timeout' => self::DEFAULT_TIMEOUT,
|
||||||
'verify' => \RX_BASEDIR . 'common/vendor/composer/ca-bundle/res/cacert.pem',
|
'verify' => \RX_BASEDIR . 'common/vendor/composer/ca-bundle/res/cacert.pem',
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
// Add proxy settings.
|
||||||
|
if (defined('__PROXY_SERVER__'))
|
||||||
|
{
|
||||||
|
$proxy = parse_url(constant('__PROXY_SERVER__'));
|
||||||
|
$proxy_scheme = preg_match('/^(https|socks)/', $proxy['scheme'] ?? '') ? ($proxy['scheme'] . '://') : 'http://';
|
||||||
|
$proxy_auth = (!empty($proxy['user']) && !empty($proxy['pass'])) ? ($proxy['user'] . ':' . $proxy['pass'] . '@') : '';
|
||||||
|
$settings['proxy'] = sprintf('%s%s%s:%s', $proxy_scheme, $proxy_auth, $proxy['host'], $proxy['port']);
|
||||||
|
}
|
||||||
|
|
||||||
|
self::$_client = new \GuzzleHttp\Client($settings);
|
||||||
}
|
}
|
||||||
return self::$_client;
|
return self::$_client;
|
||||||
}
|
}
|
||||||
|
|
@ -274,15 +286,6 @@ class HTTP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the proxy.
|
|
||||||
if (!isset($settings['proxy']) && defined('__PROXY_SERVER__'))
|
|
||||||
{
|
|
||||||
$proxy = parse_url(constant('__PROXY_SERVER__'));
|
|
||||||
$proxy_scheme = preg_match('/^socks/', $proxy['scheme'] ?? '') ? ($proxy['scheme'] . '://') : 'http://';
|
|
||||||
$proxy_auth = (!empty($proxy['user']) && !empty($proxy['pass'])) ? ($proxy['user'] . ':' . $proxy['pass'] . '@') : '';
|
|
||||||
$settings['proxy'] = sprintf('%s%s%s:%s', $proxy_scheme, $proxy_auth, $proxy['host'], $proxy['port']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue