Equations
- Network.HTTP.Req.instBEqScheme.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
HTTP and HTTPS schemes are distinct (enables auth separation).
A correct-by-construction URL parameterized by scheme.
The scheme phantom parameter enables HTTPS-only auth enforcement. Hostname is proven non-empty by construction. Path segments are stored in order.
$$\text{Url}\ s = \{ \text{host} : \{h : \text{String} \mid h.\text{length} > 0\},\; \text{segments} : \text{List String} \}$$
- host : String
The hostname. Must be non-empty (enforced by proof).
Path segments (e.g., ["api", "v1", "users"]).
Host is non-empty (proof, erased at runtime).
Instances For
Equations
- One or more equations did not get rendered due to their size.
Construct an HTTP URL from a hostname. $$\text{http} : \text{String} \to \text{Url .Http}$$
Equations
- Network.HTTP.Req.http host h = { host := host, host_nonempty := h }
Instances For
Construct an HTTPS URL from a hostname. $$\text{https} : \text{String} \to \text{Url .Https}$$
Equations
- Network.HTTP.Req.https host h = { host := host, host_nonempty := h }
Instances For
Append a path segment to a URL. $$(\text{/:}) : \text{Url}\ s \to \text{String} \to \text{Url}\ s$$
Equations
Instances For
Infix operator for path segments: https "api.example.com" /: "v1" /: "users"
Equations
- One or more equations did not get rendered due to their size.
Instances For
Get the default port for a URL based on its scheme.
Equations
- x_1.defaultPort = 80
- x_1.defaultPort = 443
Instances For
Whether an HTTP method allows a request body. $$\text{CanHaveBody} = \text{YesBody} \mid \text{NoBody}$$
- YesBody : CanHaveBody
- NoBody : CanHaveBody
Instances For
Equations
Equations
- Network.HTTP.Req.instBEqCanHaveBody.beq x✝ y✝ = (x✝.ctorIdx == y✝.ctorIdx)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Typeclass for HTTP methods. Maps each method to its body permission and wire name. $$\text{HttpMethod}\ m = \{ \text{allowsBody} : \text{CanHaveBody},\; \text{methodName} : \text{String} \}$$
- allowsBody : CanHaveBody
Whether this method allows a request body.
- methodName : String
The HTTP method name as it appears on the wire (e.g., "GET").
Instances
Typeclass for HTTP request bodies. Maps each body type to its content and content-type. $$\text{HttpBody}\ b = \{ \text{providesBody} : \text{CanHaveBody},\; \text{getBody} : b \to \text{Option ByteArray},\; \text{getContentType} : b \to \text{Option String} \}$$
- providesBody : CanHaveBody
Whether this body type provides a body.
Get the body bytes.
nonemeans no body.Get the Content-Type header value.
Instances
Compile-time constraint: method/body compatibility.
This typeclass has instances for all valid combinations:
(.YesBody, .YesBody)— POST with body(.YesBody, .NoBody)— POST with no body (allowed)(.NoBody, .NoBody)— GET with no body
The missing instance (.NoBody, .YesBody) means that
req GET url (ReqBodyBs data) ... fails at compile time
with "failed to synthesize HttpBodyAllowed .NoBody .YesBody".
Instances
HTTP GET method. Does not allow a request body.
Instances For
HTTP HEAD method. Does not allow a request body.
Instances For
HTTP DELETE method. Does not allow a request body (matches Haskell req).
Instances For
HTTP OPTIONS method. Does not allow a request body.
Instances For
HTTP TRACE method. Does not allow a request body.
Instances For
HTTP CONNECT method. Does not allow a request body.
Instances For
Equations
- Network.HTTP.Req.instHttpMethodGET = { allowsBody := Network.HTTP.Req.CanHaveBody.NoBody, methodName := "GET" }
Equations
- Network.HTTP.Req.instHttpMethodPOST = { allowsBody := Network.HTTP.Req.CanHaveBody.YesBody, methodName := "POST" }
Equations
- Network.HTTP.Req.instHttpMethodHEAD = { allowsBody := Network.HTTP.Req.CanHaveBody.NoBody, methodName := "HEAD" }
Equations
- Network.HTTP.Req.instHttpMethodPUT = { allowsBody := Network.HTTP.Req.CanHaveBody.YesBody, methodName := "PUT" }
Equations
- Network.HTTP.Req.instHttpMethodDELETE = { allowsBody := Network.HTTP.Req.CanHaveBody.NoBody, methodName := "DELETE" }
Equations
- Network.HTTP.Req.instHttpMethodPATCH = { allowsBody := Network.HTTP.Req.CanHaveBody.YesBody, methodName := "PATCH" }
Equations
- Network.HTTP.Req.instHttpMethodOPTIONS = { allowsBody := Network.HTTP.Req.CanHaveBody.NoBody, methodName := "OPTIONS" }
Equations
- Network.HTTP.Req.instHttpMethodTRACE = { allowsBody := Network.HTTP.Req.CanHaveBody.NoBody, methodName := "TRACE" }
Equations
- Network.HTTP.Req.instHttpMethodCONNECT = { allowsBody := Network.HTTP.Req.CanHaveBody.NoBody, methodName := "CONNECT" }
No request body. Used with GET, HEAD, DELETE, etc.
Instances For
Equations
- Network.HTTP.Req.instHttpBodyNoReqBody = { providesBody := Network.HTTP.Req.CanHaveBody.NoBody, getBody := fun (x : Network.HTTP.Req.NoReqBody) => none }
Equations
- One or more equations did not get rendered due to their size.
Lazy ByteArray body (same as strict for now; lazy distinction is for API compatibility).
- bytes : ByteArray
Instances For
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Typeclass for HTTP response interpretation.
Defines how to parse the raw Network.HTTP.Client.Response into
a typed response value.
$$\text{HttpResponse}\ r = \{ \text{interpretResponse} : \text{Response} \to \text{IO}\ r,\; \text{acceptHeader} : \text{Option String} \}$$
- interpretResponse : Client.Response → IO r
Parse a raw HTTP response into the typed response.
Optional Accept header value to send with the request.
Instances
Ignore the response body. Only status and headers are returned.
- status : Types.Status
Response status.
- headers : Types.ResponseHeaders
Response headers.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
Equations
- Network.HTTP.Req.instHttpResponseIgnoreResponse = { interpretResponse := fun (resp : Network.HTTP.Client.Response) => pure { status := resp.statusCode, headers := resp.headers } }
Strict ByteArray response — returns the full body as a ByteArray.
- status : Types.Status
Response status.
- headers : Types.ResponseHeaders
Response headers.
- body : ByteArray
Response body.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Select IgnoreResponse as the response type.
Equations
- Network.HTTP.Req.ignoreResponse = { status := Network.HTTP.Types.status200, headers := [] }
Instances For
Select BsResponse as the response type.
Equations
- Network.HTTP.Req.bsResponse = { status := Network.HTTP.Types.status200, headers := [], body := ByteArray.empty }
Instances For
Composable request options, parameterized by scheme.
Forms a Monoid via Append / EmptyCollection. The scheme
phantom parameter enables HTTPS-only authentication enforcement:
basicAuth returns ReqOption .Https, so it can only be passed
to req when the URL is also Url .Https.
$$\text{ReqOption}\ s = \{ \text{extraHeaders},\; \text{queryParams},\; \text{portOverride},\; \text{timeout} \}$$
- extraHeaders : Types.RequestHeaders
Extra headers to add to the request.
Extra query parameters (key, value).
Override the default port.
Response timeout in milliseconds.
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
ReqOption append is associative for the list-based fields.
Add a custom header to the request.
Instances For
Set the response timeout in milliseconds.
Equations
- Network.HTTP.Req.responseTimeout ms = { timeout := some ms }
Instances For
Basic authentication. HTTPS-only enforced by the return type ReqOption .Https.
Using this with an http URL is a compile-time error: the type
ReqOption .Https does not unify with ReqOption .Http.
$$\text{basicAuth} : \text{String} \to \text{String} \to \text{ReqOption .Https}$$
Equations
- One or more equations did not get rendered due to their size.
Instances For
OAuth 2.0 bearer token. HTTPS-only. $$\text{oAuth2Bearer} : \text{String} \to \text{ReqOption .Https}$$
Equations
Instances For
OAuth 2.0 token (alternative form). HTTPS-only.
Equations
Instances For
Unsafe basic auth that works over any scheme. The caller is responsible for transport security.
Equations
- One or more equations did not get rendered due to their size.
Instances For
HTTP client configuration.
Controls redirect following, timeouts, and response validation.
The redirectCount_le proof prevents unbounded redirect following.
$$\text{HttpConfig} = \{ \text{redirectCount} : \{n : \mathbb{N} \mid n \leq 100\},\; \text{timeout},\; \text{checkResponse} \}$$
- httpConfigRedirectCount : Nat
Maximum number of redirects to follow.
- httpConfigTimeout : Nat
Default response timeout in milliseconds. 0 = no timeout.
- httpConfigCheckResponse : Types.Status → Option String
Custom response validation. Return
some errorMsgto throw on non-2xx. Redirect count is bounded (prevents unbounded recursion).
Instances For
Default HTTP config with sensible defaults.
Equations
- Network.HTTP.Req.defaultHttpConfig = { redirectCount_le := Network.HTTP.Req.defaultHttpConfig._proof_2 }
Instances For
The Req monad: IO with HTTP configuration via ReaderT pattern. $$\text{Req}\ \alpha = \text{HttpConfig} \to \text{IO}\ \alpha$$
- run : HttpConfig → IO α
The underlying computation, a function from config to IO.
Instances For
Equations
- Network.HTTP.Req.instFunctorReq = { map := fun {α β : Type} (f : α → β) (x : Network.HTTP.Req.Req α) => { run := fun (cfg : Network.HTTP.Req.HttpConfig) => f <$> x.run cfg } }
Equations
- Network.HTTP.Req.instPureReq = { pure := fun {α : Type} (a : α) => { run := fun (x : Network.HTTP.Req.HttpConfig) => pure a } }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Network.HTTP.Req.instMonadLiftIOReq = { monadLift := fun {α : Type} (action : IO α) => { run := fun (x : Network.HTTP.Req.HttpConfig) => action } }
The MonadHttp typeclass. Any monad that can perform HTTP requests.
- getHttpConfig : m HttpConfig
Get the current HTTP configuration.
Handle an HTTP exception.
Lift an IO action into the monad.
Instances
Equations
- One or more equations did not get rendered due to their size.
Run a Req computation with the given configuration.
$$\text{runReq} : \text{HttpConfig} \to \text{Req}\ \alpha \to \text{IO}\ \alpha$$
Equations
- Network.HTTP.Req.runReq config action = action.run config
Instances For
Make a type-safe HTTP request.
This is the central function of the library. Type parameters enforce correctness at compile time:
methodmust be anHttpMethod(GET, POST, etc.)bodymust be anHttpBody(NoReqBody, ReqBodyBs, etc.)responsemust be anHttpResponse(IgnoreResponse, BsResponse, etc.)HttpBodyAllowedensures GET cannot carry a bodyschemeflows throughUrlandReqOption, ensuring HTTPS-only auth
$$\text{req} : m \to \text{Url}\ s \to b \to r \to \text{ReqOption}\ s \to \text{Req}\ r$$
Equations
- One or more equations did not get rendered due to their size.
Instances For
Look up a header value in the response (case-insensitive).
Equations
- r.responseHeader name = Option.map Prod.snd (List.find? (fun (x : Network.HTTP.Types.Header) => match x with | (n, snd) => n == name) r.headers)
Instances For
Look up a header value in an IgnoreResponse.
Equations
- r.responseHeader name = Option.map Prod.snd (List.find? (fun (x : Network.HTTP.Types.Header) => match x with | (n, snd) => n == name) r.headers)