File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,13 +84,33 @@ public function __invoke(RequestInterface $request, array $options)
8484 if (isset ($ userinfo [1 ]))
8585 {
8686 list ($ username , $ password ) = $ userinfo ;
87+ if ('' === $ password )
88+ {
89+ $ password = null ;
90+ }
8791 }
8892 else
8993 {
90- $ username = $ userinfo [0 ];
91- $ password = '' ;
94+ $ username = '' === $ userinfo [ 0 ] ? null : $ userinfo [0 ];
95+ $ password = null ;
9296 }
93- $ yurunRequest = $ yurunRequest ->withAttribute (Attributes::PROXY_SERVER , $ proxyUri ->getHost ())
97+ switch ($ options ['curl ' ][\CURLOPT_PROXYTYPE ] ?? \CURLPROXY_HTTP )
98+ {
99+ case \CURLPROXY_HTTP :
100+ case \CURLPROXY_HTTP_1_0 :
101+ case \CURLPROXY_HTTPS :
102+ $ proxyScheme = 'http ' ;
103+ break ;
104+ case \CURLPROXY_SOCKS5 :
105+ case \CURLPROXY_SOCKS5_HOSTNAME :
106+ $ proxyScheme = 'socks5 ' ;
107+ break ;
108+ default :
109+ throw new \RuntimeException ('Guzzle-Swoole only supports HTTP and socks5 proxies ' );
110+ }
111+ $ yurunRequest = $ yurunRequest ->withAttribute (Attributes::USE_PROXY , true )
112+ ->withAttribute (Attributes::PROXY_TYPE , $ proxyScheme )
113+ ->withAttribute (Attributes::PROXY_SERVER , $ proxyUri ->getHost ())
94114 ->withAttribute (Attributes::PROXY_PORT , $ proxyUri ->getPort ())
95115 ->withAttribute (Attributes::PROXY_USERNAME , $ username )
96116 ->withAttribute (Attributes::PROXY_PASSWORD , $ password );
You can’t perform that action at this time.
0 commit comments