flix

0.70.0

Net.HttpRequest

enum HttpRequestSource
case HttpRequest({ body = Option[Body], connectTimeout = Option[Duration], followRedirects = Bool, headers = Map[String, List[String]], method = Method, requestTimeout = Option[Duration], url = String })

An HTTP request with method, URL, multi-valued headers, and optional body.

Definitions

def body(r: HttpRequest): Option[String] Source

Returns the text body of the request r, or None if absent or binary.

def bodyBytes(r: HttpRequest): Option[Vector[Int8]] Source

Returns the binary body of the request r, or None if absent or text.

def connectTimeout(r: HttpRequest): Option[Duration] Source

Returns the connect timeout of the request r.

def delete(url: String): HttpRequest Source

Creates a DELETE request to the given url.

def followRedirects(r: HttpRequest): Bool Source

Returns true if the request r follows redirects.

def get(url: String): HttpRequest Source

Creates a GET request to the given url.

def head(url: String): HttpRequest Source

Creates a HEAD request to the given url.

def headers(r: HttpRequest): Map[String, List[String]] Source

Returns the headers of the request r.

def method(r: HttpRequest): Method Source

Returns the HTTP method of the request r.

def options(url: String): HttpRequest Source

Creates an OPTIONS request to the given url.

def patch(url: String, body: String): HttpRequest Source

Creates a PATCH request to the given url with the given body.

def post(url: String, body: String): HttpRequest Source

Creates a POST request to the given url with the given body.

def put(url: String, body: String): HttpRequest Source

Creates a PUT request to the given url with the given body.

def requestTimeout(r: HttpRequest): Option[Duration] Source

Returns the request timeout of the request r.

def setHeader(name: String, value: String, r: HttpRequest): HttpRequest Source

Sets the header name to value on the request r, replacing any existing values.

def url(r: HttpRequest): String Source

Returns the URL of the request r.

def withAccept(accept: String, r: HttpRequest): HttpRequest Source

Sets the Accept header to accept on the request r.

def withBearerToken(token: String, r: HttpRequest): HttpRequest Source

Sets the Authorization header to Bearer <token> on the request r.

def withBody(body: String, r: HttpRequest): HttpRequest Source

Sets the body of the request r to the given text body.

def withBodyBytes(body: Vector[Int8], r: HttpRequest): HttpRequest Source

Sets the body of the request r to the given binary body.

def withConnectTimeout(d: Duration, r: HttpRequest): HttpRequest Source

Sets the connect timeout (time to establish the TCP connection).

def withContentType(contentType: String, r: HttpRequest): HttpRequest Source

Sets the Content-Type header to contentType on the request r.

def withFollowRedirects(follow: Bool, r: HttpRequest): HttpRequest Source

Sets whether the request r should follow HTTP redirects.

def withHeader(name: String, value: String, r: HttpRequest): HttpRequest Source

Adds the header name with value value to the request r.

If the header already exists, the value is appended to the list of values.

def withHeaders(h: Map[String, List[String]], r: HttpRequest): HttpRequest Source

Merges the given headers h into the request r.

For headers that already exist, the new values are appended to the existing values.

def withQueryParam(name: String, value: String, r: HttpRequest): HttpRequest Source

Appends a query parameter name=value to the URL of the request r.

The name and value are URL-encoded.

def withQueryParams(params: Map[String, String], r: HttpRequest): HttpRequest Source

Appends multiple query parameters to the URL of the request r.

The names and values are URL-encoded.

def withTimeout(d: Duration, r: HttpRequest): HttpRequest Source

Sets the request timeout (time until response headers are received).