Merge pull request #1245 from nupplaphil/feat/http_client_arg

[various] Introduce explicit HttpClient "Accept" parameter
pull/1246/head
Hypolite Petovan 2022-04-08 14:36:55 -04:00 committed by GitHub
commit 5101253aa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -19,6 +19,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
@ -207,7 +208,7 @@ function mailstream_do_images(&$item, &$attachments)
continue;
}
$cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-');
$curlResult = DI::httpClient()->fetchFull($url, 0, '', $cookiejar);
$curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar);
$attachments[$url] = [
'data' => $curlResult->getBody(),
'guid' => hash("crc32", $url),

View File

@ -22,6 +22,7 @@ use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Protocol\Activity;
use Friendica\Protocol\ActivityNamespace;
@ -1487,7 +1488,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
function pumpio_reachable($url)
{
return DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => 10])->isSuccess();
return DI::httpClient()->get($url, HttpClientAccept::DEFAULT, [HttpClientOptions::TIMEOUT => 10])->isSuccess();
}
/*

View File

@ -56,6 +56,7 @@ use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Model\Post;
use Friendica\Model\User;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
@ -1367,7 +1368,7 @@ function statusnet_convertmsg(App $a, $body)
} elseif ($oembed_data->type != "link") {
$body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
} else {
$img_str = DI::httpClient()->fetch($expanded_url, 4);
$img_str = DI::httpClient()->fetch($expanded_url, HttpClientAccept::DEFAULT, 4);
$tempfile = tempnam(System::getTempPath(), "cache");
file_put_contents($tempfile, $img_str);