net.http

+http-response-handler+

abort!

added in 3.0

(abort! ws)

Closes this WebSocket’s input and output abruptly.

call-api

added in 4.1.4

(call-api path method opts)(call-api base-url path method {:keys [path-params query-params header-params cookie-params body content-type accepts], :as opts})

Call an API by making an HTTP request and return its response.

close!

added in 3.0

(close! ws)(close! ws status-code reason)

Initiates an orderly closure of this WebSocket’s output by sending a Close message with the given status code and the reason.

decode-jwt

(decode-jwt jwt)

delete

(delete url)(delete url opts)

encode-form-params

(encode-form-params params)

event-stream

added in 4.0

(event-stream url & [opts])

creates a data-stream for checking errors

get

(get url)(get url opts)

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-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

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

send!

added in 3.0

(send! ws data)(send! ws data {:keys [last?], :or {last? true}})

Sends a message to the WebSocket.

data can be a CharSequence (e.g. string) or ByteBuffer

stream-lines

added in 4.0

(stream-lines is callback)

reads lines from a stream

url-encode

(url-encode s)

websocket

added in 3.0

(websocket uri {:keys [on-open on-message on-ping on-pong on-close on-error], :as opts})

Builds a new WebSocket connection from a request object and returns a future connection.

Arguments:

  • uri a websocket uri
  • opts (optional), a map of:
  • :http-client An HttpClient - will use a default HttpClient if not provided
  • :listener A WebSocket$Listener - alternatively will be created from the handlers passed into opts: :on-open, :on-message, :on-ping, :on-pong, :on-close, :on-error
  • :headers Adds the given name-value pair to the list of additional HTTP headers sent during the opening handshake.
  • :connect-timeout Sets a timeout for establishing a WebSocket connection (in millis).
  • :subprotocols Sets a request for the given subprotocols.