pub struct ArchiveClient { /* fields omitted */ }
A Client that serves as a wrapper around the archive.is capture service
Creates a new instance of the ArchiveClient
using the provided user agent or a dummy one.
Invokes the archive.is capture service an each url supplied.
If no token was passed, a fresh token is obtained via get_unique_token
,
afterwards all capture requests are joined in a single future that returns
a Vec<Result<Archived, Error>>
which holds every result of the individual
capturing requests, so every single capture request gets executed regardless
of the success of prior requests.
Invokes the archive.is capture service.
First it get's the current valid unique submitid
by calling get_unique_id
.
Then it sends a new POST request to the archive.is submit endpoint with the url
and the
submitid
encoded as x-www-form-urlencoded
in the body.
The link to the archived page is then contained in the Refresh
header of the Response.
It also tries to parse the timemap from the Date
header and packs it together with the url
in a new Archived
instance.
Invokes the archive.is capture service directly without retrieving a submit id first.
This can have the advantage that no additional request is necessary, but poses potential
drawbacks when the id
is not valid. Generally the temporarily ``` are still valid
even when the archiv.is server switched to a new one in the meantime. But it might be the
case, that the server returns a Server Error
, In that case a Error::MissingUrl(url)
is
returned containing the requested url.
Switching to the ordinary capture
method would also be possible but that could result in
undesired cyclic behavior.
There might also be the possibility, where the response body already
contains the html of the archived url
. In that case we read the archive.is url from the
html's meta information instead.
In order to submit an authorized capture request we need to first obtain a temporarily valid
unique token.
This is achieved by sending a GET request to the archive.is domain and parsing the
submitid` from the responding html.