PluginProbe
Authorizer / 3.9.1
Authorizer v3.9.1
3.16.0 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 All 127 releases
← All changes | vendor/google/auth/src/HttpHandler/Guzzle6HttpHandler.php +3 -84 3.15.13.9.1 View file →
@@ -15,22 +15,14 @@
15 15 * limitations under the License.
16 16 */
17 17 namespace Google\Auth\HttpHandler;
18 18
19 -use Google\Auth\Logging\LoggingTrait;
20 -use Google\Auth\Logging\RpcLogEvent;
21 19 use GuzzleHttp\ClientInterface;
22 20 use Psr\Http\Message\RequestInterface;
23 21 use Psr\Http\Message\ResponseInterface;
24 -use Psr\Log\LoggerInterface;
25 22
26 -/**
27 - * @deprecated Guzzle 6 is no longer supported; use Guzzle7HttpHandler.
28 - */
29 23 class Guzzle6HttpHandler
30 24 {
31 - use LoggingTrait;
32 -
33 25 /**
34 26 * @var ClientInterface
35 27 */
36 28 private $client;
@@ -35,20 +27,13 @@
35 27 */
36 28 private $client;
37 29
38 30 /**
39 - * @var null|LoggerInterface
40 - */
41 - private $logger;
42 -
43 - /**
44 31 * @param ClientInterface $client
45 - * @param null|LoggerInterface $logger
46 32 */
47 - public function __construct(ClientInterface $client, ?LoggerInterface $logger = null)
33 + public function __construct(ClientInterface $client)
48 34 {
49 35 $this->client = $client;
50 - $this->logger = $logger;
51 36 }
52 37
53 38 /**
54 39 * Accepts a PSR-7 request and an array of options and returns a PSR-7 response.
@@ -58,21 +43,9 @@
58 43 * @return ResponseInterface
59 44 */
60 45 public function __invoke(RequestInterface $request, array $options = [])
61 46 {
62 - $requestEvent = null;
63 -
64 - if ($this->logger) {
65 - $requestEvent = $this->requestLog($request, $options);
66 - }
67 -
68 - $response = $this->client->send($request, $options);
69 -
70 - if ($this->logger) {
71 - $this->responseLog($response, $requestEvent);
72 - }
73 -
74 - return $response;
47 + return $this->client->send($request, $options);
75 48 }
76 49
77 50 /**
78 51 * Accepts a PSR-7 request and an array of options and returns a PromiseInterface
@@ -83,61 +56,7 @@
83 56 * @return \GuzzleHttp\Promise\PromiseInterface
84 57 */
85 58 public function async(RequestInterface $request, array $options = [])
86 59 {
87 - $requestEvent = null;
88 -
89 - if ($this->logger) {
90 - $requestEvent = $this->requestLog($request, $options);
91 - }
92 -
93 - $promise = $this->client->sendAsync($request, $options);
94 -
95 - if ($this->logger) {
96 - $promise->then(function (ResponseInterface $response) use ($requestEvent) {
97 - $this->responseLog($response, $requestEvent);
98 - return $response;
99 - });
100 - }
101 -
102 - return $promise;
103 - }
104 -
105 - /**
106 - * @internal
107 - * @param RequestInterface $request
108 - * @param array<mixed> $options
109 - */
110 - public function requestLog(RequestInterface $request, array $options): RpcLogEvent
111 - {
112 - $requestEvent = new RpcLogEvent();
113 -
114 - $requestEvent->method = $request->getMethod();
115 - $requestEvent->url = (string) $request->getUri();
116 - $requestEvent->headers = $request->getHeaders();
117 - $requestEvent->payload = $request->getBody()->getContents();
118 - $requestEvent->retryAttempt = $options['retryAttempt'] ?? null;
119 - $requestEvent->serviceName = $options['serviceName'] ?? null;
120 - $requestEvent->processId = (int) getmypid();
121 - $requestEvent->requestId = $options['requestId'] ?? crc32((string) spl_object_id($request) . getmypid());
122 -
123 - $this->logRequest($requestEvent);
124 -
125 - return $requestEvent;
126 - }
127 -
128 - /**
129 - * @internal
130 - */
131 - public function responseLog(ResponseInterface $response, RpcLogEvent $requestEvent): void
132 - {
133 - $responseEvent = new RpcLogEvent($requestEvent->milliseconds);
134 -
135 - $responseEvent->headers = $response->getHeaders();
136 - $responseEvent->payload = $response->getBody()->getContents();
137 - $responseEvent->status = $response->getStatusCode();
138 - $responseEvent->processId = $requestEvent->processId;
139 - $responseEvent->requestId = $requestEvent->requestId;
140 -
141 - $this->logResponse($responseEvent);
60 + return $this->client->sendAsync($request, $options);
142 61 }
143 62 }