Closed ssnepenthe closed 2 years ago
Had the same today, quite curious if this is indeed intended.
For anyone who stumbles on this in the future...
After revisiting this I noticed that the Goutte client extends the BrowserKit HttpBrowser, which in turn extends AbstractBrowser.
AbstractBrowser passes the URI through a method called getAbsoluteUri which can build an absolute URI by using the HTTPS and HTTP_HOST server parameters.
So you can effectively get the same result as configuring the base_uri setting with something like the following:
$goutte = new Goutte\Client;
$goutte->setServerParameter('HTTPS', true);
$goutte->setServerParameter('HTTP_HOST', 'duckduckgo.com');
$response = $goutte->request('GET', '/about');
$response->getUri(); // "https://duckduckgo.com/about"
Closing as it seems this is indeed intended as explained here.
Hopefully I'm not missing anything obvious here...
The last time I used Goutte was before the switch to the Symfony Http Client. I could configure the Guzzle client with a base uri and Goutte would honor it.
So for example I might do something like this before:
With the latest version, I can still set a base uri on the http client and it works as expected:
But when I give that client to goutte it no longer works:
Is this intended behavior?