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.
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
, then the function catches a new submit_id
and then tries to capture the url
again. This is done by switching to the general capture
function in case of error.
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 identifier, or none could be found.
This is achieved by sending a GET request to the archive.is domain and parsing the
submitid` from the responding html.