Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / fabpot / goutte / Goutte / Client.php
index af4923ed12b19109fb0090bf5172d611ee0c8c90..9be8ea7733337bf73ae4788a9f845357181dedb0 100644 (file)
@@ -16,6 +16,7 @@ use GuzzleHttp\ClientInterface as GuzzleClientInterface;
 use GuzzleHttp\Cookie\CookieJar;
 use GuzzleHttp\Exception\RequestException;
 use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\UriInterface;
 use Symfony\Component\BrowserKit\Client as BaseClient;
 use Symfony\Component\BrowserKit\Request;
 use Symfony\Component\BrowserKit\Response;
@@ -26,18 +27,42 @@ use Symfony\Component\BrowserKit\Response;
  * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  * @author Michael Dowling <michael@guzzlephp.org>
  * @author Charles Sarrazin <charles@sarraz.in>
+ * @author Kévin Dunglas <dunglas@gmail.com>
  */
 class Client extends BaseClient
 {
     protected $client;
 
     private $headers = array();
-    private $auth = null;
+    private $auth;
 
     public function setClient(GuzzleClientInterface $client)
     {
         $this->client = $client;
 
+        /**
+         * @var $baseUri UriInterface
+         */
+        if (null !== $this->getServerParameter('HTTP_HOST', null) || null === $baseUri = $client->getConfig('base_uri')) {
+            return $this;
+        }
+
+        $path = $baseUri->getPath();
+        if ('' !== $path && '/' !== $path) {
+            throw new \InvalidArgumentException('Setting a path in the Guzzle "base_uri" config option is not supported by Goutte yet.');
+        }
+
+        if (null === $this->getServerParameter('HTTPS', null) && 'https' === $baseUri->getScheme()) {
+            $this->setServerParameter('HTTPS', 'on');
+        }
+
+        $host = $baseUri->getHost();
+        if (null !== $port = $baseUri->getPort()) {
+            $host .= ":$port";
+        }
+
+        $this->setServerParameter('HTTP_HOST', $host);
+
         return $this;
     }