Skip to main content

http_get

Function http_get 

Source
pub async fn http_get(
    address: &Address,
    path: &str,
    limit: Duration,
) -> Result<HttpResponse, Error>
Expand description

Makes one plain-HTTP GET request for path at an http address.

The request is HTTP/1.0, so the server answers without chunked encoding and closes the connection after the response. The body ends at Content-Length when the response has one, at the head for a 204 or 304, and at the end of the connection otherwise. A response with a Transfer-Encoding other than identity, or with a body over the courier’s limit of a few MiB, is malformed.

limit bounds the call, but a name lookup it cuts short keeps running on its blocking thread until the resolver answers.

§Errors

Fails with Error::Unsupported for any address but http, and Error::InvalidPath for a path that does not start with / or holds whitespace. Fails with Error::Target when the connection, the write or a read fails, Error::MalformedResponse when the answer is not an HTTP/1 response, and Error::TimedOut when limit passes.