janus/http-client-jetty
A Jetty 9–12 implementation of the janus/http-client HttpClient protocol.
Use this as the ::http/impl backing for janus/http-client.
Setup
Add the dependency:
;; deps.edn
{janus/http-client-jetty {:mvn/version "..."}}
janus/http-client-jetty does not bring Jetty as a transitive dependency.
You must add the Jetty artifacts you want to use explicitly.
Jetty 9.x, 10.x, 11.x, and 12.x are all supported (tested with 9 and 11).
|
Usage
The public API is in janus.http.client.jetty.api.
Call jetty/create with a config map to obtain an HttpClient implementation.
(require '[janus.http.client.jetty.api :as jetty])
;; Minimal — all defaults
(def impl (jetty/create {}))
;; With custom config
(def impl (jetty/create {::jetty/connect-timeout 3000
::jetty/max-threads 50}))
Configuration options
| Option | Default | Description |
|---|---|---|
|
|
Follow HTTP redirects automatically. |
|
|
DNS resolution timeout in milliseconds. |
|
|
TCP connection timeout in milliseconds. |
|
|
Idle connection timeout in milliseconds. |
|
|
Maximum pooled connections per target host. |
|
|
Thread pool maximum size. |
|
|
Thread pool minimum size. |
|
|
Maximum number of in-flight requests before backpressure is applied (returns a |
|
— |
Classpath path to a trust store resource. |
|
— |
Password for the classpath trust store. |
|
— |
A |
|
|
Validate TLS hostnames against the server certificate. |
|
|
SOCKS4 proxy hostname. Only used when |
|
— |
SOCKS4 proxy port. Setting this enables the proxy. |
Using with janus/http-client
Pass the value returned by jetty/create as ::http/impl:
(require '[clojure.core.async :refer [<!!]]
'[io.forward-publishing.janus.http-client :as http]
'[janus.http.client.jetty.api :as jetty])
(with-open [client (http/create ::http/impl (jetty/create {}))]
(<!! (http/submit client "https://example.com")))
See janus/http-client for the full client API.