Skip to content

Commit

Permalink
Fix #24
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Nov 20, 2020
1 parent 4961d6f commit 8dfc439
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/SwooleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,33 @@ public function __invoke(RequestInterface $request, array $options)
if (isset($userinfo[1]))
{
list($username, $password) = $userinfo;
if ('' === $password)
{
$password = null;
}
}
else
{
$username = $userinfo[0];
$password = '';
$username = '' === $userinfo[0] ? null : $userinfo[0];
$password = null;
}
$yurunRequest = $yurunRequest->withAttribute(Attributes::PROXY_SERVER, $proxyUri->getHost())
switch ($options['curl'][\CURLOPT_PROXYTYPE] ?? \CURLPROXY_HTTP)
{
case \CURLPROXY_HTTP:
case \CURLPROXY_HTTP_1_0:
case \CURLPROXY_HTTPS:
$proxyScheme = 'http';
break;
case \CURLPROXY_SOCKS5:
case \CURLPROXY_SOCKS5_HOSTNAME:
$proxyScheme = 'socks5';
break;
default:
throw new \RuntimeException('Guzzle-Swoole only supports HTTP and socks5 proxies');
}
$yurunRequest = $yurunRequest->withAttribute(Attributes::USE_PROXY, true)
->withAttribute(Attributes::PROXY_TYPE, $proxyScheme)
->withAttribute(Attributes::PROXY_SERVER, $proxyUri->getHost())
->withAttribute(Attributes::PROXY_PORT, $proxyUri->getPort())
->withAttribute(Attributes::PROXY_USERNAME, $username)
->withAttribute(Attributes::PROXY_PASSWORD, $password);
Expand Down

0 comments on commit 8dfc439

Please sign in to comment.