Expand description
Fetching documents from other servers.
A fetch is a GET through the guarded Client, signed when the caller
gives a key so that a server requiring authorized fetch answers it. The
fetcher follows redirects itself: a signature covers the URL it was made
for, so each hop is checked and signed again for where it goes, and a
redirect from https to http is refused. A signed GET that is refused
is tried once in the other scheme, as a delivery is, and the fetcher
remembers which scheme each host accepted.
Fetcher::document returns a document only when it may be trusted as
what it says it is: it came as ActivityPub, it is a JSON object with an
id, and that id has the origin of the URL it was finally served from.
Anyone can serve a document naming any id, and the only thing that
vouches for an unsigned one is where it came from. Fetcher::lookup
goes one step further, as Mastodon does: a document whose id is on
another origin is fetched again from its id, once, and trusted only if
the owner of the id serves it.
A portable object, whose id is an ap:// IRI, is never trusted from a
fetch alone: its origin is a key, and only its proof vouches for it.
Fetcher::portable asks its gateways for it and keeps the first copy
whose proof holds; Fetcher::lookup sends a portable URL there.
Fetcher::walk goes through a collection’s items, a page at a time.
A web page that is not itself a document may name the document it shows
in an alternate link: link_header_alternate and html_alternate
find it, for an application resolving a URL someone pasted, as Mastodon’s
FetchResourceService does.
Structs§
- Document
- A document, fetched and established as what it says it is.
- Fetcher
- Fetches from other servers. Cheap to share; one per process is enough.
- Typed
- A document fetched, established and read into a vocabulary type.
- Walk
- A walk through a collection’s items; see
Fetcher::walk. - Walk
Limits - How far a
Walkgoes. - WebLink
- One entry of a
Linkheader (RFC 8288).
Enums§
- Fetch
Error - Why a fetch did not produce a document.
Constants§
- ACTIVITY_
ACCEPT - What a fetch asks for: ActivityStreams, in either of its media types.
- ACTIVITY_
LINK_ TYPES - The types an alternate link has to carry to name an ActivityPub object,
in the order they are looked for: Mastodon’s
FetchResourceService::ACTIVITY_STREAM_LINK_TYPES. - PORTABLE_
ACCEPT - What a gateway is asked for, as FEP-ef61 has it.
Functions§
- html_
alternate - The target of the page’s first
<link rel="alternate">of anACTIVITY_LINK_TYPEStype, resolved againstbase, the URL the page was served from. Mastodon only meets absolute targets here, and resolving a relative one costs nothing. - is_
activity_ content_ type - Whether
content_typeis ActivityStreams:application/activity+json, orapplication/ld+jsonwith the ActivityStreams profile. Plain JSON is not enough; a server that lets its users upload files would otherwise serve documents in its own name that none of its actors wrote. - link_
header_ alternate - The target of the first
Linkheader’srel="alternate"entry of anACTIVITY_LINK_TYPEStype, as written. - parse_
link_ header - The entries of a
Linkheader. A comma inside<…>or a quoted parameter value does not separate entries, and an entry without a<target>is passed over.