/** * It connects to the url and give response. * * @param PrestashopRestClientParameters $clientParameters * * @return \Guzzle\Http\Message\Response * * @throws \Exception */ protected function connect($clientParameters) { $parametersHash = $clientParameters->getHash(); if (!isset($this->resultCache[$parametersHash])) { $guzzleParams = ['connect_timeout' => self::CONNECT_TIMEOUT, 'timeout' => self::TIMEOUT, 'auth' => [$clientParameters->getHttpLogin(), $clientParameters->getHttpPassword()]]; $request = $this->client->get($clientParameters->getPrestashopUrl(), [], $guzzleParams); $request->getCurlOptions()->set(CURLOPT_CONNECTTIMEOUT, self::CONNECT_TIMEOUT); $request->getCurlOptions()->set(CURLOPT_TIMEOUT, self::TIMEOUT); try { $response = $this->client->send($request); $this->resultCache[$parametersHash] = $response; } catch (\Exception $e) { $this->resultCache[$parametersHash] = $e; throw $e; } } else { $response = $this->resultCache[$parametersHash]; if ($response instanceof \Exception) { throw $response; } } return $response; }
/** * {@inheritDoc} */ public function getContent($url) { $response = $this->client->get($url)->send(); return (string) $response->getBody(); }