PluginProbe
Authorizer / 3.9.1
Authorizer v3.9.1
3.15.3 3.15.2 3.15.1 3.15.0 3.14.3 3.14.4 3.14.2 3.14.1 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.10 2.9.11 2.9.12 2.9.13 2.9.2 2.9.3 2.9.6 All 126 releases
← All changes | vendor/google/auth/src/HttpHandler/HttpHandlerFactory.php +18 -18 3.15.13.9.1 View file →
@@ -15,15 +15,13 @@
15 15 * limitations under the License.
16 16 */
17 17 namespace Google\Auth\HttpHandler;
18 18
19 -use Google\Auth\ApplicationDefaultCredentials;
20 19 use GuzzleHttp\BodySummarizer;
21 20 use GuzzleHttp\Client;
22 21 use GuzzleHttp\ClientInterface;
23 22 use GuzzleHttp\HandlerStack;
24 23 use GuzzleHttp\Middleware;
25 -use Psr\Log\LoggerInterface;
26 24
27 25 class HttpHandlerFactory
28 26 {
29 27 /**
@@ -28,19 +26,16 @@
28 26 {
29 27 /**
30 28 * Builds out a default http handler for the installed version of guzzle.
31 29 *
32 - * @param ClientInterface|null $client
33 - * @param null|false|LoggerInterface $logger
34 - * @return Guzzle6HttpHandler|Guzzle7HttpHandler
30 + * @param ClientInterface $client
31 + * @return Guzzle5HttpHandler|Guzzle6HttpHandler|Guzzle7HttpHandler
35 32 * @throws \Exception
36 33 */
37 - public static function build(
38 - ?ClientInterface $client = null,
39 - null|false|LoggerInterface $logger = null,
40 - ) {
34 + public static function build(ClientInterface $client = null)
35 + {
41 36 if (is_null($client)) {
42 - $config = [];
37 + $stack = null;
43 38 if (class_exists(BodySummarizer::class)) {
44 39 // double the # of characters before truncation by default
45 40 $bodySummarizer = new BodySummarizer(240);
46 41 $stack = HandlerStack::create();
@@ -45,21 +40,26 @@
45 40 $bodySummarizer = new BodySummarizer(240);
46 41 $stack = HandlerStack::create();
47 42 $stack->remove('http_errors');
48 43 $stack->unshift(Middleware::httpErrors($bodySummarizer), 'http_errors');
49 - $config['handler'] = $stack;
50 44 }
51 - $client = new Client($config);
45 + $client = new Client(['handler' => $stack]);
52 46 }
53 47
54 - $logger = ($logger === false)
55 - ? null
56 - : $logger ?? ApplicationDefaultCredentials::getDefaultLogger();
48 + $version = null;
49 + if (defined('GuzzleHttp\ClientInterface::MAJOR_VERSION')) {
50 + $version = ClientInterface::MAJOR_VERSION;
51 + } elseif (defined('GuzzleHttp\ClientInterface::VERSION')) {
52 + $version = (int) substr(ClientInterface::VERSION, 0, 1);
53 + }
57 54
58 - switch (ClientInterface::MAJOR_VERSION) {
55 + switch ($version) {
56 + case 5:
57 + return new Guzzle5HttpHandler($client);
58 + case 6:
59 + return new Guzzle6HttpHandler($client);
59 60 case 7:
60 - case 8:
61 - return new Guzzle7HttpHandler($client, $logger);
61 + return new Guzzle7HttpHandler($client);
62 62 default:
63 63 throw new \Exception('Version not supported');
64 64 }
65 65 }