From 1d0a0b927b625e1a82e1bf0e9b6f49fa7b267848 Mon Sep 17 00:00:00 2001 From: Dag Date: Wed, 18 May 2022 00:18:33 +0200 Subject: [PATCH] fix: use accept header when fetching feed (#2737) * fix: use accept header when fetching feed * fix: include atom too, and reuse constants from format classes * add a catch all accept header --- lib/FeedExpander.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/FeedExpander.php b/lib/FeedExpander.php index 44ec19e0..58d830b7 100644 --- a/lib/FeedExpander.php +++ b/lib/FeedExpander.php @@ -91,7 +91,14 @@ abstract class FeedExpander extends BridgeAbstract { /* Notice we do not use cache here on purpose: * we want a fresh view of the RSS stream each time */ - $content = getContents($url) + + $mimeTypes = [ + MrssFormat::MIME_TYPE, + AtomFormat::MIME_TYPE, + '*/*', + ]; + $httpHeaders = ['Accept: ' . implode(', ', $mimeTypes)]; + $content = getContents($url, $httpHeaders) or returnServerError('Could not request ' . $url); $rssContent = simplexml_load_string(trim($content));