Merge pull request #11378 from nupplaphil/feat/accept
Add Default Accept for HTTP Calls
This commit is contained in:
commit
e09e1b2336
1 changed files with 7 additions and 1 deletions
|
@ -26,7 +26,6 @@ use Friendica\Network\HTTPClient\Response\CurlResult;
|
||||||
use Friendica\Network\HTTPClient\Response\GuzzleResponse;
|
use Friendica\Network\HTTPClient\Response\GuzzleResponse;
|
||||||
use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
|
use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
|
||||||
use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses;
|
use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses;
|
||||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
|
@ -44,6 +43,9 @@ use Psr\Log\LoggerInterface;
|
||||||
*/
|
*/
|
||||||
class HttpClient implements ICanSendHttpRequests
|
class HttpClient implements ICanSendHttpRequests
|
||||||
{
|
{
|
||||||
|
/** @var string Default value for "Accept" header */
|
||||||
|
const DEFAULT_ACCEPT = '*/*';
|
||||||
|
|
||||||
/** @var LoggerInterface */
|
/** @var LoggerInterface */
|
||||||
private $logger;
|
private $logger;
|
||||||
/** @var Profiler */
|
/** @var Profiler */
|
||||||
|
@ -141,6 +143,10 @@ class HttpClient implements ICanSendHttpRequests
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (empty($conf[HttpClientOptions::HEADERS]['Accept'])) {
|
||||||
|
$conf[HttpClientOptions::HEADERS]['Accept'] = static::DEFAULT_ACCEPT;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->logger->debug('http request config.', ['url' => $url, 'method' => $method, 'options' => $conf]);
|
$this->logger->debug('http request config.', ['url' => $url, 'method' => $method, 'options' => $conf]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue