Request

is a request data type. It holds the verb of the request, the version, the uri, the cookies, the headers, and the body.

body

instantiate

(Fn [(Ref Request a)] (Ref String a))

gets the body property of a Request.

chunked?

defn

(Fn [(Ref Request a)] Bool)

                        (chunked? r)
                    

checks whether the request body is chunked transfer-encoded, i.e. its Transfer-Encoding header lists chunked (case-insensitively). Decode such a body with TransferEncoding.dechunk.

cookies

instantiate

(Fn [(Ref Request a)] (Ref (Array Cookie) a))

gets the cookies property of a Request.

copy

instantiate

(Fn [(Ref Request a)] Request)

copies a Request.

del

defn

(Fn [URI, (Array Cookie), (Map String (Array String)), String] Request)

                        (del uri cookies headers body)
                    

builds a HTTP DELETE request (version 1.1).

delete

instantiate

(Fn [Request] ())

deletes a Request. Should usually not be called manually.

form-data

defn

(Fn [(Ref Request a)] (Result (Map String String) b))

                        (form-data r)
                    

parses the request body as URL-encoded form data. Returns (Result (Map String String) String).

get

defn

(Fn [URI, (Array Cookie), (Map String (Array String)), String] Request)

                        (get uri cookies headers body)
                    

builds a HTTP GET request (version 1.1).

defn

(Fn [(Ref Request a), (Ref String b)] (Maybe String))

                        (header r name)
                    

gets the first value of a header by name (case-insensitive). Returns (Maybe String).

headers

instantiate

(Fn [(Ref Request a)] (Ref (Map String (Array String)) a))

gets the headers property of a Request.

ignore-body?

defn

(Fn [(Ref Request a)] Bool)

                        (ignore-body? r)
                    

checks whether the body of the request should be ignored.

init

instantiate

(Fn [String, String, URI, (Array Cookie), (Map String (Array String)), String] Request)

creates a Request.

multipart-data

defn

(Fn [(Ref Request a)] (Result (Array FormPart) String))

                        (multipart-data r)
                    

parses the request body as multipart/form-data, taking the boundary from the Content-Type header. Returns (Result (Array FormPart) String); fails when the request is not multipart/form-data or carries no boundary.

negotiate

defn

(Fn [(Ref Request a), (Ref (Array String) b)] (Maybe String))

                        (negotiate r offers)
                    

chooses the best response media type for this request from the server's offers, honoring the request's Accept header (RFC 7231 §5.3.2). A request with no Accept header accepts anything. See Accept.negotiate.

negotiate-encoding

defn

(Fn [(Ref Request a), (Ref (Array String) b)] (Maybe String))

                        (negotiate-encoding r offers)
                    

chooses the best content coding for this request's response from the server's offers, honoring the request's Accept-Encoding header (RFC 9110 §12.5.3). A request with no Accept-Encoding header accepts anything and yields the first offer, whereas one with an empty header accepts only identity. See AcceptEncoding.negotiate.

negotiate-language

defn

(Fn [(Ref Request a), (Ref (Array String) b)] (Maybe String))

                        (negotiate-language r offers)
                    

chooses the best language for this request's response from the server's offers, honoring the request's Accept-Language header (RFC 4647 §3.3.1). A request with no Accept-Language header accepts anything. See AcceptLanguage.negotiate.

parse

defn

(Fn [(Ref String a)] (Result Request String))

                        (parse txt)
                    

parses a HTTP request from a string txt.

Returns an (Error String) holding the error message if it fails, otherwise it will return a (Success Request).

patch

defn

(Fn [URI, (Array Cookie), (Map String (Array String)), String] Request)

                        (patch uri cookies headers body)
                    

builds a HTTP PATCH request (version 1.1).

post

defn

(Fn [URI, (Array Cookie), (Map String (Array String)), String] Request)

                        (post uri cookies headers body)
                    

builds a HTTP POST request (version 1.1).

prn

instantiate

(Fn [(Ref Request a)] String)

converts a Request to a string.

put

defn

(Fn [URI, (Array Cookie), (Map String (Array String)), String] Request)

                        (put uri cookies headers body)
                    

builds a HTTP PUT request (version 1.1).

range

defn

(Fn [(Ref Request a)] (Maybe (Result (Array ByteRangeSpec) String)))

                        (range r)
                    

the byte ranges this request asks for, as (Maybe (Result (Array ByteRangeSpec) String)). Nothing when it carries no Range header. See ByteRange.parse, whose Error means the header is one RFC 9110 §14.2 has the server ignore — serving the whole representation rather than a 416.

request

defn

(Fn [String, URI, (Array Cookie), (Map String (Array String)), String] Request)

                        (request verb uri cookies headers body)
                    

builds a HTTP 1.1 request.

set-body

instantiate

(Fn [Request, String] Request)

sets the body property of a Request.

set-body!

instantiate

(Fn [(Ref Request a), String] ())

sets the body property of a Request in place.

set-cookies

instantiate

(Fn [Request, (Array Cookie)] Request)

sets the cookies property of a Request.

set-cookies!

instantiate

(Fn [(Ref Request a), (Array Cookie)] ())

sets the cookies property of a Request in place.

set-headers

instantiate

(Fn [Request, (Map String (Array String))] Request)

sets the headers property of a Request.

set-headers!

instantiate

(Fn [(Ref Request a), (Map String (Array String))] ())

sets the headers property of a Request in place.

set-uri

instantiate

(Fn [Request, URI] Request)

sets the uri property of a Request.

set-uri!

instantiate

(Fn [(Ref Request a), URI] ())

sets the uri property of a Request in place.

set-verb

instantiate

(Fn [Request, String] Request)

sets the verb property of a Request.

set-verb!

instantiate

(Fn [(Ref Request a), String] ())

sets the verb property of a Request in place.

set-version

instantiate

(Fn [Request, String] Request)

sets the version property of a Request.

set-version!

instantiate

(Fn [(Ref Request a), String] ())

sets the version property of a Request in place.

str

defn

(Fn [(Ref Request a)] String)

                        (str r)
                    

stringifies the request as it looks on the wire.

update-body

instantiate

(Fn [Request, (Ref (Fn [String] String a) b)] Request)

updates the body property of a Request using a function f.

update-cookies

instantiate

(Fn [Request, (Ref (Fn [(Array Cookie)] (Array Cookie) a) b)] Request)

updates the cookies property of a Request using a function f.

update-headers

instantiate

(Fn [Request, (Ref (Fn [(Map String (Array String))] (Map String (Array String)) a) b)] Request)

updates the headers property of a Request using a function f.

update-uri

instantiate

(Fn [Request, (Ref (Fn [URI] URI a) b)] Request)

updates the uri property of a Request using a function f.

update-verb

instantiate

(Fn [Request, (Ref (Fn [String] String a) b)] Request)

updates the verb property of a Request using a function f.

update-version

instantiate

(Fn [Request, (Ref (Fn [String] String a) b)] Request)

updates the version property of a Request using a function f.

uri

instantiate

(Fn [(Ref Request a)] (Ref URI a))

gets the uri property of a Request.

verb

instantiate

(Fn [(Ref Request a)] (Ref String a))

gets the verb property of a Request.

version

instantiate

(Fn [(Ref Request a)] (Ref String a))

gets the version property of a Request.