Module http

Module http 

Source
Expand description

HTTP client.

This module is a thin wrapper around the isahc crate that just limits the API surface to only async methods without the async suffix. You can convert from/into that isahc types and this one.

§Examples

Get some text:

let text = task::http::get_txt("https://httpbin.org/base64/SGVsbG8gV29ybGQ=").await?;
println!("{text}!");

Modules§

header
HTTP header types
uri
URI component of request and response lines

Structs§

Body
HTTP request body.
CacheKey
Represents a SHA-512/256 hash computed from a normalized request.
CachePolicy
Represents a serializable configuration for a cache entry in a CacheDb.
Client
HTTP client.
ClientBuilder
Builder that can be used to create a Client.
Cookie
Information stored about an HTTP cookie.
CookieJar
Provides automatic cookie session management using an in-memory cookie store.
DefaultAlreadyInitedError
Error returned by set_default_client_init if the default was already initialized.
FileSystemCache
A simple CacheDb implementation that uses a local directory.
Method
The Request Method (VERB)
Metrics
Information about the state of an HTTP request.
Request
HTTP request.
RequestBuilder
A Request builder.
Response
HTTP response.
StatusCode
An HTTP status code (status-code in RFC 7230 et al.).
Uri
The URI component of a request.

Enums§

CacheMode
Cache mode selected for a Uri.
Error
An error encountered while sending an HTTP request or receiving an HTTP response using a Client.
RedirectPolicy
Describes a policy for handling server redirects.

Statics§

METRICS_ID
Metrics in a Progress::with_meta metadata.

Traits§

CacheDb
Represents a download cache in a Client.
TryBody
Marker trait for types that try-to-convert to Body.
TryHeaderName
Marker trait for types that try-to-convert to header::HeaderName.
TryHeaderValue
Marker trait for types that try-to-convert to header::HeaderValue.
TryMethod
Marker trait for types that try-to-convert to Method.
TryUri
Marker trait for types that try-to-convert to Uri.

Functions§

default_client
The Client used by the functions in this module.
delete
Send a DELETE request to the uri.
get
Send a GET request to the uri.
get_bytes
Send a GET request to the uri and read the response as raw bytes.
get_json
Send a GET request to the uri and de-serializes the response.
get_txt
Send a GET request to the uri and read the response as a string.
head
Send a HEAD request to the uri.
post
Send a POST request to the uri with a given request body.
put
Send a PUT request to the uri with a given request body.
send
Send a custom Request.
set_default_client_init
Set a custom initialization function for the default_client.

Type Aliases§

ResponseParts
Head parts from a split Response.