use Friendica\Model\Contact;
use Friendica\Model\User;
use Friendica\Network\CurlResult;
+use Friendica\Network\HTTPClientOptions;
use Friendica\Network\IHTTPResult;
/**
public static function createSig($head, $prvkey, $keyid = 'Key')
{
$return_headers = [];
+ if (!empty($head)) {
+ $return_headers = $head;
+ }
$alg = 'sha512';
$algorithm = 'rsa-sha512';
$headerval = 'keyId="' . $keyid . '",algorithm="' . $algorithm
. '",headers="' . $x['headers'] . '",signature="' . $x['signature'] . '"';
- $sighead = 'Authorization: Signature ' . $headerval;
-
- if ($head) {
- foreach ($head as $k => $v) {
- $return_headers[] = $k . ': ' . $v;
- }
- }
-
- $return_headers[] = $sighead;
+ $return_headers['Authorization'] = ['Signature ' . $headerval];
return $return_headers;
}
$fields = '';
foreach ($head as $k => $v) {
+ if (is_array($v)) {
+ $v = implode(', ', $v);
+ }
$headers .= strtolower($k) . ': ' . trim($v) . "\n";
if ($fields) {
$fields .= ' ';
$headers['Content-Type'] = 'application/activity+json';
- $postResult = DI::httpRequest()->post($target, $content, $headers);
+ $postResult = DI::httpClient()->post($target, $content, $headers);
$return_code = $postResult->getReturnCode();
Logger::log('Transmit to ' . $target . ' returned ' . $return_code, Logger::DEBUG);
$header['Signature'] = 'keyId="' . $owner['url'] . '#main-key' . '",algorithm="rsa-sha256",headers="(request-target) date host",signature="' . $signature . '"';
}
- $curl_opts = $opts;
- $curl_opts['header'] = $header;
+ $curl_opts = $opts;
+ $curl_opts[HTTPClientOptions::HEADERS] = $header;
if (!empty($opts['nobody'])) {
- $curlResult = DI::httpRequest()->head($request, $curl_opts);
+ $curlResult = DI::httpClient()->head($request, $curl_opts);
} else {
- $curlResult = DI::httpRequest()->get($request, $curl_opts);
+ $curlResult = DI::httpClient()->get($request, $curl_opts);
}
$return_code = $curlResult->getReturnCode();