Discovery
NAME
Syndicate::Discovery - Feed URL discovery and fetching
SYNOPSIS
use Syndicate::Discovery;
my $disc = Syndicate::Discovery.new;
my $feed = $disc.fetch("https://example.com/feed.xml");
my $feed = $disc.discover("https://example.com");
my @urls = $disc.find-feeds($html, $base-url);
DESCRIPTION
Fetches feeds from URLs and discovers feed URLs from HTML pages.
Parses <link> tags with rel="alternate" for
RSS, Atom, and JSON Feed content types.
METHODS
fetch(Str $url)
Fetches a URL and parses the feed. Dies on HTTP errors.
Security note: SSL/TLS certificates are not verified by the default
HTTP::Tiny user agent. Neither HTTP::Tiny nor the underlying
IO::Socket::SSL module support certificate verification. For connections
requiring TLS verification, pass a custom :$ua. The custom user agent must
duck-type HTTP::Tiny: respond to .get(Str $url) with a Hash whose
success, status, reason, content, and headers keys behave like
HTTP::Tiny's response (content-type, content-length, location
headers). Note that Cro::HTTP::Client and HTTP::UserAgent do not
satisfy this contract as-is.
Responses are limited to MAX-FEED-SIZE bytes (10 MiB). The Content-Length
header is checked before the body is accepted, and the buffered body is
re-checked afterwards; a server that streams a body without a
Content-Length header is therefore still fully buffered before the limit
is enforced.
discover(Str $url)
Fetches a URL, tries to parse as a feed. If that fails, searches the HTML
for <link> feed tags and fetches the first discovered feed URL.
Security note: DNS rebinding within the validation/request window is theoretically possible but impractical for single-request feed fetching. The validation runs immediately before each HTTP request, making the TOCTOU window very small.
find-feeds(Str $html, Str $base-url -- Array)>
Returns an array of feed URLs found in HTML by scanning <link>
tags with rel="alternate" and appropriate type attributes.