From 80a533ddab9ee4ec7b715ff2dc92e1e464ccd85d Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 26 Mar 2022 22:15:44 +0100 Subject: [PATCH] Add Default Accept for HTTP Calls --- src/Network/HTTPClient/Client/HttpClient.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Network/HTTPClient/Client/HttpClient.php b/src/Network/HTTPClient/Client/HttpClient.php index f6d0cf5774..ae34defc41 100644 --- a/src/Network/HTTPClient/Client/HttpClient.php +++ b/src/Network/HTTPClient/Client/HttpClient.php @@ -26,7 +26,6 @@ use Friendica\Network\HTTPClient\Response\CurlResult; use Friendica\Network\HTTPClient\Response\GuzzleResponse; use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests; use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses; -use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Util\Network; use Friendica\Util\Profiler; use GuzzleHttp\Client; @@ -44,6 +43,9 @@ use Psr\Log\LoggerInterface; */ class HttpClient implements ICanSendHttpRequests { + /** @var string Default value for "Accept" header */ + const DEFAULT_ACCEPT = '*/*'; + /** @var LoggerInterface */ private $logger; /** @var Profiler */ @@ -141,6 +143,10 @@ class HttpClient implements ICanSendHttpRequests } }; + if (empty($conf[HttpClientOptions::HEADERS]['Accept'])) { + $conf[HttpClientOptions::HEADERS]['Accept'] = static::DEFAULT_ACCEPT; + } + try { $this->logger->debug('http request config.', ['url' => $url, 'method' => $method, 'options' => $conf]);