Move the UA definition in HttpClientFactory before L67

This commit is contained in:
Adrien ERAUD
2024-12-10 17:01:02 +01:00
parent 6624993225
commit 3b77706657

View File

@ -64,6 +64,14 @@ class HttpClientFactory implements ClientFactory
{
$this->logger->log('debug', 'Restricted access config enabled?', ['enabled' => (int) $this->restrictedAccess]);
if (!isset($config['defaults']['headers'])) {
$config['defaults']['headers'] = [];
}
if (!isset($config['defaults']['headers']['User-Agent'])) {
// need to set the user-agent
$config['defaults']['headers']['User-Agent'] = $this->userAgent;
}
if (0 === (int) $this->restrictedAccess) {
return new GuzzleAdapter(new GuzzleClient($config));
}
@ -75,14 +83,6 @@ class HttpClientFactory implements ClientFactory
$config['defaults']['cookies'] = $this->cookieJar;
}
if (!isset($config['defaults']['headers'])) {
$config['defaults']['headers'] = [];
}
if (!isset($config['defaults']['headers']['User-Agent'])) {
// need to set the user-agent
$config['defaults']['headers']['User-Agent'] = $this->userAgent;
}
$guzzle = new GuzzleClient($config);
foreach ($this->subscribers as $subscriber) {
$guzzle->getEmitter()->attach($subscriber);