Function activitypub_federation::fetch::fetch_object_http
source · pub async fn fetch_object_http<T: Clone, Kind: DeserializeOwned>(
url: &Url,
data: &Data<T>
) -> Result<FetchObjectResponse<Kind>, Error>
Expand description
Fetch a remote object over HTTP and convert to Kind
.
crate::fetch::object_id::ObjectId::dereference wraps this function to add caching and conversion to database type. Only use this function directly in exceptional cases where that behaviour is undesired.
Every time an object is fetched via HTTP, [RequestData.request_counter] is incremented by one. If the value exceeds [FederationSettings.http_fetch_limit], the request is aborted with Error::RequestLimit. This prevents denial of service attacks where an attack triggers infinite, recursive fetching of data.
The Accept
header will be set to the content of FEDERATION_CONTENT_TYPE
. When parsing the
response it ensures that it has a valid Content-Type
header as defined by ActivityPub, to
prevent security vulnerabilities like this one.
Additionally it checks that the id
field is identical to the fetch URL (after redirects).