]> git.mxchange.org Git - friendica.git/commitdiff
Use appropriate "accept" values
authorMichael <heluecht@pirati.ca>
Wed, 30 Mar 2022 14:39:53 +0000 (14:39 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 30 Mar 2022 14:39:53 +0000 (14:39 +0000)
mod/redir.php
src/Model/Profile.php
src/Network/HTTPClient/Client/HttpClient.php
src/Network/Probe.php
src/Protocol/Salmon.php

index 5a707d229cd3524b5ff36c47a5fc1246c5d6f054..dc086ae19a2347387c3541df6db5bff6e65f9cdb 100644 (file)
@@ -144,7 +144,7 @@ function redir_magic($a, $cid, $url)
        }
 
        // 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()) {
                $separator = strpos($target_url, '?') ? '&' : '?';
                $target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
index 3a453cc87522c08f245207aab790c393bdeb4396..85af2030013b7ba6d85b0b99f2c6c19e471bbcdd 100644 (file)
@@ -751,7 +751,7 @@ class Profile
                        $magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
 
                        // 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()) {
                                Logger::info('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path);
                                System::externalRedirect($magic_path);
index e8e77a6b017ee12512505c9845c98ccfb0ead428..8cb2d9cb609771745caafde9fb07862d97cc53ba 100644 (file)
@@ -44,19 +44,20 @@ use Psr\Log\LoggerInterface;
 class HttpClient implements ICanSendHttpRequests
 {
        /** @var string Default value for "Accept" header */
-       const ACCEPT_DEFAULT  = '*/*';
-       const ACCEPT_ATOM_XML = 'application/atom+xml,text/xml;q=0.9,*/*;q=0.8';
-       const ACCEPT_FEED_XML = 'application/atom+xml,application/rss+xml;q=0.9,application/rdf+xml;q=0.8,text/xml;q=0.7,*/*;q=0.6';
-       const ACCEPT_HTML     = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
-       const ACCEPT_IMAGE    = 'image/png,image/jpeg,image/gif,image/*;q=0.9,*/*;q=0.8';
-       const ACCEPT_JRD_JSON = 'application/jrd+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_MAGIC    = 'application/magic-envelope+xml';
-       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_VIDEO    = 'video/mp4,video/*;q=0.9,*/*;q=0.8';
-       const ACCEPT_XRD_XML  = 'application/xrd+xml,text/xml;q=0.9,*/*;q=0.8';
+       const ACCEPT_DEFAULT   = '*/*';
+       const ACCEPT_ATOM_XML  = 'application/atom+xml,text/xml;q=0.9,*/*;q=0.8';
+       const ACCEPT_FEED_XML  = 'application/atom+xml,application/rss+xml;q=0.9,application/rdf+xml;q=0.8,text/xml;q=0.7,*/*;q=0.6';
+       const ACCEPT_HTML      = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
+       const ACCEPT_IMAGE     = 'image/png,image/jpeg,image/gif,image/*;q=0.9,*/*;q=0.8';
+       const ACCEPT_JRD_JSON  = 'application/jrd+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_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_TEXT      = 'text/plain,text/*;q=0.9,*/*;q=0.8';
+       const ACCEPT_VIDEO     = 'video/mp4,video/*;q=0.9,*/*;q=0.8';
+       const ACCEPT_XRD_XML   = 'application/xrd+xml,text/xml;q=0.9,*/*;q=0.8';
 
        /** @var LoggerInterface */
        private $logger;
index b347f235a968fa4c2c418ee56af0a195d5d6bba3..51fb84261b171e19468d93dbe48d7bcc712b800b 100644 (file)
@@ -1527,7 +1527,7 @@ class Probe
                                                        $pubkey = substr($pubkey, 5);
                                                }
                                        } 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()) {
                                                        self::$istimeout = true;
                                                        return $short ? false : [];
index 4fcef9177317024704ce5d2a30cde595a01b6ddc..2f12cdf1c80d641d1329da16e1059d6efbb973f1 100644 (file)
@@ -73,7 +73,7 @@ class Salmon
                                                $ret[$x] = substr($ret[$x], 5);
                                        }
                                } 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]]);
                                }
                        }