mirror of
https://github.com/friendica/friendica
synced 2025-05-01 08:24:23 +02:00
Introduce "accept_header" as specific argument to the http client
This commit is contained in:
parent
73c3b21665
commit
e299fc67c8
35 changed files with 150 additions and 150 deletions
|
@ -61,11 +61,11 @@ class ParseUrl
|
|||
*/
|
||||
public static function getContentType(string $url, string $accept = HttpClientAccept::DEFAULT)
|
||||
{
|
||||
$curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => $accept]);
|
||||
$curlResult = DI::httpClient()->head($url, $accept);
|
||||
|
||||
// Workaround for systems that can't handle a HEAD request
|
||||
if (!$curlResult->isSuccess() && ($curlResult->getReturnCode() == 405)) {
|
||||
$curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::ACCEPT_CONTENT => $accept]);
|
||||
$curlResult = DI::httpClient()->get($url, $accept, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
|
||||
}
|
||||
|
||||
if (!$curlResult->isSuccess()) {
|
||||
|
@ -222,7 +222,7 @@ class ParseUrl
|
|||
return $siteinfo;
|
||||
}
|
||||
|
||||
$curlResult = DI::httpClient()->get($url, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
|
||||
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
|
||||
Logger::info('Empty body or error when fetching', ['url' => $url, 'success' => $curlResult->isSuccess(), 'code' => $curlResult->getReturnCode()]);
|
||||
return $siteinfo;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue