Use appropriate "accept" values
This commit is contained in:
parent
3e21b035b7
commit
2ca51f752d
5 changed files with 18 additions and 17 deletions
|
@ -144,7 +144,7 @@ function redir_magic($a, $cid, $url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test for magic auth on the target system
|
// Test for magic auth on the target system
|
||||||
$serverret = DI::httpClient()->get($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
|
$serverret = DI::httpClient()->head($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
|
||||||
if ($serverret->isSuccess()) {
|
if ($serverret->isSuccess()) {
|
||||||
$separator = strpos($target_url, '?') ? '&' : '?';
|
$separator = strpos($target_url, '?') ? '&' : '?';
|
||||||
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
|
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
|
||||||
|
|
|
@ -751,7 +751,7 @@ class Profile
|
||||||
$magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
|
$magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
|
||||||
|
|
||||||
// We have to check if the remote server does understand /magic without invoking something
|
// We have to check if the remote server does understand /magic without invoking something
|
||||||
$serverret = DI::httpClient()->get($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
|
$serverret = DI::httpClient()->head($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
|
||||||
if ($serverret->isSuccess()) {
|
if ($serverret->isSuccess()) {
|
||||||
Logger::info('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path);
|
Logger::info('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path);
|
||||||
System::externalRedirect($magic_path);
|
System::externalRedirect($magic_path);
|
||||||
|
|
|
@ -53,6 +53,7 @@ class HttpClient implements ICanSendHttpRequests
|
||||||
const ACCEPT_JSON = 'application/json,*/*;q=0.9';
|
const ACCEPT_JSON = 'application/json,*/*;q=0.9';
|
||||||
const ACCEPT_JSON_AS = 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
|
const ACCEPT_JSON_AS = 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"';
|
||||||
const ACCEPT_MAGIC = 'application/magic-envelope+xml';
|
const ACCEPT_MAGIC = 'application/magic-envelope+xml';
|
||||||
|
const ACCEPT_MAGIC_KEY = 'application/magic-public-key';
|
||||||
const ACCEPT_RSS_XML = 'application/rss+xml,text/xml;q=0.9,*/*;q=0.8';
|
const ACCEPT_RSS_XML = 'application/rss+xml,text/xml;q=0.9,*/*;q=0.8';
|
||||||
const ACCEPT_TEXT = 'text/plain,text/*;q=0.9,*/*;q=0.8';
|
const ACCEPT_TEXT = 'text/plain,text/*;q=0.9,*/*;q=0.8';
|
||||||
const ACCEPT_VIDEO = 'video/mp4,video/*;q=0.9,*/*;q=0.8';
|
const ACCEPT_VIDEO = 'video/mp4,video/*;q=0.9,*/*;q=0.8';
|
||||||
|
|
|
@ -1527,7 +1527,7 @@ class Probe
|
||||||
$pubkey = substr($pubkey, 5);
|
$pubkey = substr($pubkey, 5);
|
||||||
}
|
}
|
||||||
} elseif (Strings::normaliseLink($pubkey) == 'http://') {
|
} elseif (Strings::normaliseLink($pubkey) == 'http://') {
|
||||||
$curlResult = DI::httpClient()->get($pubkey, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
|
$curlResult = DI::httpClient()->get($pubkey, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_MAGIC_KEY]);
|
||||||
if ($curlResult->isTimeout()) {
|
if ($curlResult->isTimeout()) {
|
||||||
self::$istimeout = true;
|
self::$istimeout = true;
|
||||||
return $short ? false : [];
|
return $short ? false : [];
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Salmon
|
||||||
$ret[$x] = substr($ret[$x], 5);
|
$ret[$x] = substr($ret[$x], 5);
|
||||||
}
|
}
|
||||||
} elseif (Strings::normaliseLink($ret[$x]) == 'http://') {
|
} elseif (Strings::normaliseLink($ret[$x]) == 'http://') {
|
||||||
$ret[$x] = DI::httpClient()->fetch($ret[$x], 0, HttpClient::ACCEPT_DEFAULT);
|
$ret[$x] = DI::httpClient()->fetch($ret[$x], 0, HttpClient::ACCEPT_MAGIC_KEY);
|
||||||
Logger::debug('Fetched public key', ['url' => $ret[$x]]);
|
Logger::debug('Fetched public key', ['url' => $ret[$x]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue