I'm searching a way to configure Drupal's HTTP Client Guzzle. I.e. the base_url and user agent.
The Guzzle docs provide info here: http://docs.guzzlephp.org/en/latest/quickstart.html#creating-a-client
But nothing that works with the Drupal implementation.
I can see in core/lib/Drupal/Core/Http/ClientFactory.php that there is a default config with which the Guzzle Client constructor is fed.
//Line 46-65:
public function fromOptions(array $config = []) {
$default_config = [
// Security consideration: we must not use the certificate authority
// file shipped with Guzzle because it can easily get outdated if a
// certificate authority is hacked. Instead, we rely on the certificate
// authority file provided by the operating system which is more likely
// going to be updated in a timely fashion. This overrides the default
// path to the pem file bundled with Guzzle.
'verify' => TRUE,
'timeout' => 30,
'headers' => [
'User-Agent' => 'Drupal/' . \Drupal::VERSION . ' (+https://www.drupal.org/) ' . \GuzzleHttp\default_user_agent(),
],
'handler' => $this->stack,
];
$config = NestedArray::mergeDeep($default_config, Settings::get('http_client_config', []), $config);
return new Client($config);
}
Any way to reconfigure this?
\Drupal::httpClient()
does not provide any parameters for configuration.