From 128a00c4ab381417ac4d3be1f72ad16569534708 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 24 Feb 2016 16:48:44 +0100 Subject: [PATCH] Include feeds in Link HTTP headers, for easier discovery --- lib/feed.php | 5 +++++ lib/noticestreamaction.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/feed.php b/lib/feed.php index e04c69be6c..d61c3e8a34 100644 --- a/lib/feed.php +++ b/lib/feed.php @@ -62,6 +62,11 @@ class Feed $this->title = $title; } + function getUrl() + { + return $this->url; + } + function mimeType() { switch ($this->type) { diff --git a/lib/noticestreamaction.php b/lib/noticestreamaction.php index fb592915a7..e668a27daf 100644 --- a/lib/noticestreamaction.php +++ b/lib/noticestreamaction.php @@ -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(); }