X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=src%2FWallabag%2FCoreBundle%2FHelper%2FHttpClientFactory.php;h=ea864acbbf6a7471947e4a2e9b7689be6fdcb700;hb=3c5aa05311d057c8fed83f085e6fb6ecc874fca4;hp=4899d3d41afbfeb1bd6589d653b47481bab9e0a4;hpb=bf9ace0643f654e7ccd9c020b8b501ad56cd19de;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php index 4899d3d4..ea864acb 100644 --- a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php +++ b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php @@ -6,9 +6,9 @@ use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\Cookie\CookieJar; use GuzzleHttp\Event\SubscriberInterface; use Http\Adapter\Guzzle5\Client as GuzzleAdapter; -use Psr\Log\LoggerInterface; use Http\Client\HttpClient; use Http\HttplugBundle\ClientFactory\ClientFactory; +use Psr\Log\LoggerInterface; /** * Builds and configures the HTTP client. @@ -27,9 +27,7 @@ class HttpClientFactory implements ClientFactory /** * HttpClientFactory constructor. * - * @param \GuzzleHttp\Cookie\CookieJar $cookieJar - * @param string $restrictedAccess This param is a kind of boolean. Values: 0 or 1 - * @param LoggerInterface $logger + * @param string $restrictedAccess This param is a kind of boolean. Values: 0 or 1 */ public function __construct(CookieJar $cookieJar, $restrictedAccess, LoggerInterface $logger) { @@ -40,8 +38,6 @@ class HttpClientFactory implements ClientFactory /** * Adds a subscriber to the HTTP client. - * - * @param SubscriberInterface $subscriber */ public function addSubscriber(SubscriberInterface $subscriber) { @@ -51,8 +47,6 @@ class HttpClientFactory implements ClientFactory /** * Input an array of configuration to be able to create a HttpClient. * - * @param array $config - * * @return HttpClient */ public function createClient(array $config = []) @@ -60,13 +54,17 @@ class HttpClientFactory implements ClientFactory $this->logger->log('debug', 'Restricted access config enabled?', ['enabled' => (int) $this->restrictedAccess]); if (0 === (int) $this->restrictedAccess) { - return new GuzzleAdapter(new GuzzleClient()); + return new GuzzleAdapter(new GuzzleClient($config)); } // we clear the cookie to avoid websites who use cookies for analytics $this->cookieJar->clear(); - // need to set the (shared) cookie jar - $guzzle = new GuzzleClient(['defaults' => ['cookies' => $this->cookieJar]]); + if (!isset($config['defaults']['cookies'])) { + // need to set the (shared) cookie jar + $config['defaults']['cookies'] = $this->cookieJar; + } + + $guzzle = new GuzzleClient($config); foreach ($this->subscribers as $subscriber) { $guzzle->getEmitter()->attach($subscriber); }