forked from friendica/friendica-addons
Merge pull request #1245 from nupplaphil/feat/http_client_arg
[various] Introduce explicit HttpClient "Accept" parameter
This commit is contained in:
commit
5101253aa0
3 changed files with 6 additions and 3 deletions
|
@ -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),
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue