Include feeds in Link HTTP headers, for easier discovery

This commit is contained in:
Mikael Nordfeldth 2016-02-24 16:48:44 +01:00
parent 1d0a448e07
commit 128a00c4ab
2 changed files with 17 additions and 0 deletions

View File

@ -62,6 +62,11 @@ class Feed
$this->title = $title; $this->title = $title;
} }
function getUrl()
{
return $this->url;
}
function mimeType() function mimeType()
{ {
switch ($this->type) { switch ($this->type) {

View File

@ -34,6 +34,18 @@ abstract class NoticestreamAction extends ProfileAction
// pass by default // 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 // this fetches the NoticeStream
abstract public function getStream(); abstract public function getStream();
} }