Http
Request
Represents an HTTP request.
Method
Represents an HTTP method.
Header
Represents an HTTP header e.g. Content-Type: application/json
TimeoutConfig
Represents a timeout configuration for an HTTP request.
Response
Represents an HTTP response.
Err
Represents an HTTP error.
defaultRequest : Request
A default Request
value.
# GET "roc-lang.org" { Http.defaultRequest & url: "https://www.roc-lang.org", }
header : Str, Str -> Header
An HTTP header for configuring requests.
See common headers here.
handleStringResponse : Response -> Result Str Err
errorToString : Err -> Str
send : Request -> Task Response [HttpError Err]
Task to send an HTTP request, succeeds with a value of Str
or fails with an
Err
.
# Prints out the HTML of the Roc-lang website. response <- { Http.defaultRequest & url: "https://www.roc-lang.org" } |> Http.send |> Task.await response.body |> Str.fromUtf8 |> Result.withDefault "Invalid UTF-8" |> Stdout.line