aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dag <me@dvikan.no> 2024-03-31 21:02:55 +0200
committerGravatar GitHub <noreply@github.com> 2024-03-31 21:02:55 +0200
commit73289324bd39a31e225bd8f8048a1081bb771c67 (patch)
treee4693460377819886b664e665fce1d6d910911ca
parent8ca1b908400d2965c3ca6aa76b821b7bca7c50e0 (diff)
downloadrss-bridge-73289324bd39a31e225bd8f8048a1081bb771c67.tar.gz
rss-bridge-73289324bd39a31e225bd8f8048a1081bb771c67.tar.zst
rss-bridge-73289324bd39a31e225bd8f8048a1081bb771c67.zip
feat: add vendor http header to cached responses (#4040)
-rw-r--r--actions/DisplayAction.php2
-rw-r--r--bridges/MediapartBlogsBridge.php7
-rw-r--r--lib/FeedItem.php2
-rw-r--r--lib/http.php9
4 files changed, 15 insertions, 5 deletions
diff --git a/actions/DisplayAction.php b/actions/DisplayAction.php
index 24bdefe1..93813004 100644
--- a/actions/DisplayAction.php
+++ b/actions/DisplayAction.php
@@ -32,7 +32,7 @@ class DisplayAction implements ActionInterface
return new Response('', 304, ['last-modified' => $modificationTimeGMT . 'GMT']);
}
}
- return $cachedResponse;
+ return $cachedResponse->withHeader('rss-bridge', 'This is a cached response');
}
if (!$bridgeName) {
diff --git a/bridges/MediapartBlogsBridge.php b/bridges/MediapartBlogsBridge.php
index fa8c3d5f..d1e1c3c9 100644
--- a/bridges/MediapartBlogsBridge.php
+++ b/bridges/MediapartBlogsBridge.php
@@ -35,7 +35,12 @@ class MediapartBlogsBridge extends BridgeAbstract
$item['title'] = $item_title->innertext;
$item['uri'] = self::BASE_URI . trim($item_title->href);
- $item['author'] = $element->find('.author .subscriber', 0)->innertext;
+
+ $author = $element->find('.author .subscriber', 0);
+ if ($author) {
+ $item['author'] = $author->innertext;
+ }
+
$item['content'] = $item_divs[count($item_divs) - 2] . $item_divs[count($item_divs) - 1];
$item['timestamp'] = strtotime($element->find('.author time', 0)->datetime);
diff --git a/lib/FeedItem.php b/lib/FeedItem.php
index bd37f119..fc4549a7 100644
--- a/lib/FeedItem.php
+++ b/lib/FeedItem.php
@@ -178,7 +178,6 @@ class FeedItem
} else {
$this->author = $author;
}
- return $this;
}
public function getContent(): ?string
@@ -284,7 +283,6 @@ class FeedItem
} else {
$this->misc[$name] = $value;
}
- return $this;
}
public function toArray(): array
diff --git a/lib/http.php b/lib/http.php
index e4f9bf48..39f0c727 100644
--- a/lib/http.php
+++ b/lib/http.php
@@ -331,7 +331,14 @@ final class Response
return array_pop($header);
}
- public function withBody(string $body): Response
+ public function withHeader(string $name, string $value): self
+ {
+ $clone = clone $this;
+ $clone->headers[$name] = [$value];
+ return $clone;
+ }
+
+ public function withBody(string $body): self
{
$clone = clone $this;
$clone->body = $body;