]> git.mxchange.org Git - friendica.git/commitdiff
Add Default Accept for HTTP Calls
authorPhilipp <admin@philipp.info>
Sat, 26 Mar 2022 21:15:44 +0000 (22:15 +0100)
committerPhilipp <admin@philipp.info>
Sat, 26 Mar 2022 21:15:44 +0000 (22:15 +0100)
src/Network/HTTPClient/Client/HttpClient.php

index f6d0cf577491747ef453314a0456ca10a61f51c3..ae34defc4186bfba417cece030fdaf8ebae5784c 100644 (file)
@@ -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]);