pub fn head(uri: impl AsRef<str>) -> RequestBuilder ⓘ
Expand description
Perform a one-off HEAD
request.
§About the HTTP Method
The HTTP HEAD method requests the headers that are returned if the specified resource would be requested with an HTTP GET method. Such a request can be done before deciding to download a large resource to save bandwidth, for example.
A response to a HEAD method should not have a body. If so, it must be ignored. Even so, entity headers describing the content of the body, like Content-Length may be included in the response. They don’t relate to the body of the HEAD response, which should be empty, but to the body of similar request using the GET method would have returned as a response.
If the result of a HEAD request shows that a cached resource after a GET request is now outdated, the cache is invalidated, even if no GET request has been made.
§Panics
This will panic if a malformed URL is passed.
§Errors
Returns errors from the middleware, http backend, and network sockets.
§Examples
let string = surf::head("https://httpbin.org/head").recv_string().await?;