A thin, idiomatic Clojure wrapper around the JDK's built-in HTTP client
A thin, idiomatic Clojure wrapper around the JDK's built-in HTTP client
Reads the whole body into a byte array.
Reads the whole body into a byte array.
Hands back the raw InputStream. The caller owns it, and must close it.
Hands back the raw InputStream. The caller owns it, and must close it.
Reads the whole body and decodes it with the response's charset.
Reads the whole body and decodes it with the response's charset.
(charset-of headers)The charset advertised by a response's content-type headers, UTF-8 if absent.
Public so a ResponseTransformer can decode text the way as-string does.
The charset advertised by a response's content-type headers, UTF-8 if absent. Public so a ResponseTransformer can decode text the way `as-string` does.
(client)(client {:keys [connect-timeout-ms follow-redirects version]})Build a java.net.http.HttpClient.
Options: :connect-timeout-ms connection timeout in milliseconds (default: none) :follow-redirects :always | :normal | :never (default: :normal) :version :http-1.1 | :http-2 (default: :http-2)
Build a java.net.http.HttpClient. Options: :connect-timeout-ms connection timeout in milliseconds (default: none) :follow-redirects :always | :normal | :never (default: :normal) :version :http-1.1 | :http-2 (default: :http-2)
Used when a request supplies no :body-as.
Handles the body types the JDK client already understands: nil (no body), String, byte[], and an already-built BodyPublisher. Anything else is a caller error - reach for a transformer that knows how to serialize it.
Used when a request supplies no :body-as. Handles the body types the JDK client already understands: nil (no body), String, byte[], and an already-built BodyPublisher. Anything else is a caller error - reach for a transformer that knows how to serialize it.
Turns a request into a java.net.http BodyPublisher.
Chosen per-request with :body-as, the way :as chooses a ResponseTransformer. Receives the whole request map, not just :body, so a transformer can also look at :headers - a multipart one, say, reading its boundary off the caller's content-type.
Turns a request into a java.net.http BodyPublisher. Chosen per-request with :body-as, the way :as chooses a ResponseTransformer. Receives the whole request map, not just :body, so a transformer can also look at :headers - a multipart one, say, reading its boundary off the caller's content-type.
(->request this req)Turns the raw response body into the value put on :body.
Chosen per-request with :as. Receives the whole response map - :status,
:headers, and :body holding the raw InputStream - so a transformer can branch
on the status or read a header the charset alone would not tell it (a
multipart boundary, say); charset-of derives the charset from :headers.
Implementations that consume the stream must close it.
Turns the raw response body into the value put on :body. Chosen per-request with :as. Receives the whole response map - :status, :headers, and :body holding the raw InputStream - so a transformer can branch on the status or read a header the charset alone would not tell it (a multipart boundary, say); `charset-of` derives the charset from :headers. Implementations that consume the stream must close it.
(->response this resp)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |