]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Include feeds in Link HTTP headers, for easier discovery
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 24 Feb 2016 15:48:44 +0000 (16:48 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 24 Feb 2016 15:48:44 +0000 (16:48 +0100)
lib/feed.php
lib/noticestreamaction.php

index e04c69be6c8e7edd31037d60538333a1de0df23f..d61c3e8a3433a6e1d698809a5eeadb8e0b2bbca1 100644 (file)
@@ -62,6 +62,11 @@ class Feed
         $this->title = $title;
     }
 
+    function getUrl()
+    {
+        return $this->url;
+    }
+
     function mimeType()
     {
         switch ($this->type) {
index fb592915a7cd3ac9defdbbc7ba519021b3e04a5a..e668a27daf23830788c4a7d4e2c0f8e3a5eb1a78 100644 (file)
@@ -34,6 +34,18 @@ abstract class NoticestreamAction extends ProfileAction
         // pass by default
     }
 
+    public function extraHeaders()
+    {
+        parent::extraHeaders();
+        foreach ($this->getFeeds() as $feed) {
+            header('Link: <'.htmlspecialchars($feed->getUrl()).'>;' .
+                        ' rel="'.htmlspecialchars($feed->rel()).'";' .
+                        ' type="'.htmlspecialchars($feed->mimeType()).'"',
+                    false    // don't overwrite previous headers of this sort
+                    );
+        }
+    }
+
     // this fetches the NoticeStream
     abstract public function getStream();
 }