gleam/httpc
Types
Configuration that can be used to send HTTP requests.
To be used with dispatch and dispatch_bits.
pub opaque type Configuration
pub type ConnectError {
Posix(code: String)
TlsAlert(code: String, detail: String)
}
Constructors
-
Posix(code: String) -
TlsAlert(code: String, detail: String)
pub type HttpError {
InvalidUtf8Response
FailedToConnect(ip4: ConnectError, ip6: ConnectError)
}
Constructors
-
InvalidUtf8Response -
FailedToConnect(ip4: ConnectError, ip6: ConnectError)
Values
pub fn configure() -> Configuration
Create a new configuration with the default settings.
pub fn dispatch(
config: Configuration,
request: request.Request(String),
) -> Result(response.Response(String), HttpError)
Send a HTTP request of unicode data.
pub fn dispatch_bits(
config: Configuration,
req: request.Request(BitArray),
) -> Result(response.Response(BitArray), HttpError)
Send a HTTP request of binary data.
pub fn follow_redirects(
config: Configuration,
which: Bool,
) -> Configuration
Set whether redirects should be followed automatically.
pub fn send(
req: request.Request(String),
) -> Result(response.Response(String), HttpError)
Send a HTTP request of unicode data using the default configuration.
If you wish to use some other configuration use dispatch instead.
pub fn send_bits(
req: request.Request(BitArray),
) -> Result(response.Response(BitArray), HttpError)
Send a HTTP request of binary data using the default configuration.
If you wish to use some other configuration use dispatch_bits instead.
pub fn verify_tls(
config: Configuration,
which: Bool,
) -> Configuration
Set whether to verify the TLS certificate of the server.
This defaults to True, meaning that the TLS certificate will be verified
unless you call this function with False.
Setting this to False can make your application vulnerable to
man-in-the-middle attacks and other security risks. Do not do this unless
you are sure and you understand the risks.