getPort($request, $ssl); } $port = $params['port']; $path = $params['path'] ?? '/'; if (isset($params['query']) && is_string($params['query'])) { $path .= '?' . $params['query']; } $pool = $this->factory->get($this->getPoolName($host, $port), function () use ($host, $port, $ssl) { return $this->makeClient($host, $port, $ssl); }, $this->options); $connection = $pool->get(); $response = null; try { /** @var Client $client */ $client = $connection->getConnection(); // Init Headers $headers = $this->initHeaders($request); $settings = $this->getSettings($this->options); if (! empty($settings)) { $client->set($settings); } $beginTime = microtime(true); try { $raw = $client->request($method, $path, $headers, (string) $body); } catch (Exception $exception) { $connection->close(); $exception = new RingException($exception->getMessage()); return $this->getErrorResponse($exception, $beginTime, $effectiveUrl); } $response = $this->getResponse($raw, $beginTime, $effectiveUrl); } finally { $connection->release(); } return $response; } protected function getPoolName($host, $port) { return sprintf('guzzle.ring.handler.%s.%d', $host, $port); } }