net.http.client

+default-client+

+getter-opts+

+http-redirect+

+http-response-handler+

+http-version+

+init+

create-http-methods

macro

added in 3.0

(create-http-methods ks)

creates the standard http get, post, etc requests

delete

(delete url)(delete url opts)

endpoint-data

added in 3.0

(endpoint-data result)

gets the data returned from endpoint

(endpoint-data {:status 200 :body (str {:data 1 2 3 4 :status :return})}) => 1 2 3 4

get

(get url)(get url opts)

getter-methods

added in 3.0

(getter-methods cls)

returns methods of one argument

(keys (getter-methods java.net.http.HttpResponse)) => :body :headers :previous-response :request :ssl-session :status-code :uri :version

head

(head url)(head url opts)

http-client

added in 3.0

(http-client)(http-client opts)

constructor for java.net.http.HttpClient

(http-client) => java.net.http.HttpClient

http-client-builder

added in 3.0

(http-client-builder)(http-client-builder opts)

constructor for java.net.http.HttpClientBuilder

(http-client-builder) => java.net.http.HttpClient$Builder

http-request

added in 3.0

(http-request req)(http-request req method {:keys [expect-continue? headers timeout version body], :as opts})

constructor for java.net.http.HttpRequest

(http-request “http://www.yahoo.com”) => java.net.http.HttpRequest

http-request-builder

added in 3.0

(http-request-builder opts)

constructor for java.net.http.HttpRequestBuilder

(http-request-builder {:uri “http://www.yahoo.com”}) => java.net.http.HttpRequest$Builder

mock-endpoint

added in 3.0

(mock-endpoint handler route)(mock-endpoint handler route {:keys [format], :or {format :edn}})

creates a mock-endpoint for testing

((mock-endpoint (fn req {:status 200 :body (str {:status :return :data req})}) “/endpoint”) {:id :add :args 1 2 3}) => {:method :post, :route “/endpoint”, :body “{:id :add, :args 1 2 3}”}

patch

(patch url)(patch url opts)

post

(post url)(post url opts)

put

(put url)(put url opts)

remote

added in 3.0

(remote url {:keys [id args format], :as opts, :or {format :edn}})

creates a remote access to an endpoint

request

added in 3.0

(request req)(request uri {:keys [client as raw type callback error method handler], :as opts, :or {type :sync, as :string, method :get, client (clojure.core/deref +default-client+)}})

performs a http request

request-body

added in 3.0

(request-body body)

constructs a relevant body publisher

(request-body "") => java.net.http.HttpRequest$BodyPublisher

request-headers

added in 3.0

(request-headers headers)

constructs a relevant request header

(vec (request-headers {“Content” “html” “Tags” “a” “b” “c”})) => [“Content” “html” “Tags” “a” “Tags” “b” “Tags” “c”]

response-map

added in 3.0

(response-map resp)

constucts a map from java.net.http.HttpResponse

stream-lines

added in 4.0

(stream-lines is callback)

reads lines from a stream

wrap-get-optional

added in 3.0

(wrap-get-optional f)

wraps function, nil-punning outputs for java.util.Optional

((wrap-get-optional identity) (java.util.Optional/of “hello”)) => “hello”