Lyricdev
GitHub

class Client

pub class Client

Methods

pub static fn new(options: ClientOptions = ClientOptions { }): Client
pub mut fn get(uri: Uri): Response throws [HttpError, IoError, TimedOut, Cancelled]

Sends a GET of the URI; see send.

Errors

Throws as send does.

pub mut fn send(request: Request): Response throws [HttpError, IoError, TimedOut, Cancelled]

Sends the request and reads its response's head; the body is read from the response. Redirects are followed where the options say so (303 and, for a POST, 301 and 302 as a GET; 307 and 308 with the method kept — a body cannot be sent again); timeout spans the whole.

Errors

Throws HttpError with kind Unsupported for a scheme other than http (or https without a transport) or a URI without a host, Redirects for too many redirects or one that cannot be followed, and Protocol for a peer that does not speak HTTP/1.1; IoError where the connection fails; TimedOut where timeout passes; Cancelled where the task is cancelled. On TimedOut and Cancelled the connection is closed.

pub mut fn close(): void

Closes every idle connection.