Asynchronous HTTP Client - Clojure
Asynchronous HTTP Client - Clojure
(await response)
Waits for response processing to be finished. Returns same response.
Waits for response processing to be finished. Returns same response.
(body resp)
Gets body. If body have not yet been delivered and request hasn't failed waits for body.
Gets body. If body have not yet been delivered and request hasn't failed waits for body.
(cancelled? resp)
Checks if response has been cancelled.
Checks if response has been cancelled.
(close-websocket ws)
(content-type resp)
Gets content type from response.
Gets content type from response.
(create-client &
{:keys [compression-enabled connection-timeout follow-redirects
idle-in-pool-timeout keep-alive max-conns-per-host
max-conns-total max-redirects proxy auth read-timeout
request-timeout user-agent thread-factory ssl-context]})
Creates new Async Http Client. Arguments:
Creates new Async Http Client. Arguments: - :compression-enabled :: enable HTTP compression - :connection-timeout :: connections timeout in ms - :follow-redirects :: enable following HTTP redirects - :idle-in-pool-timeout :: idle connection in pool timeout in ms - :keep-alive :: enable HTTP keep alive, enabled by default - :max-conns-per-host :: max number of polled connections per host - :max-conns-total :: max number of total connections held open by client - :max-redirects :: max nuber of redirects to follow - :proxy :: map with proxy configuration to be used :host - proxy host :port - proxy port :protocol - (optional) protocol to communicate with proxy, :http (default, if you provide no value) and :https are allowed :user - (optional) user name to use for proxy authentication, has to be provided with :password :password - (optional) password to use for proxy authentication, has to be provided with :user - :auth :: map with authentication to be used :type - either :basic or :digest :user - user name to be used :password - password to be used :realm - realm name to authenticate in :preemptive - assume authentication is required - :read-timeout :: read timeout in ms - :request-timeout :: request timeout in ms - :user-agent :: User-Agent branding string - :thread-factory :: Provide your own ThreadFactory for callbacks to be executed with - :ssl-context :: provide your own SSL Context
(DELETE client url & {:as options})
Sends asynchronously HTTP DELETE request to url. Returns a map:
Sends asynchronously HTTP DELETE request to url. Returns a map: - :id - unique ID of request - :status - promise that once status is received is delivered, contains lazy map of: - :code - response code - :msg - response message - :protocol - protocol with version - :major - major version of protocol - :minor - minor version of protocol - :headers - promise that once headers are received is delivered, contains lazy map of: - :server - header names are keyworded, values stay not changed - :body - body of response, depends on request type, might be ByteArrayOutputStream or lazy sequence, use conveniece methods to extract it, like string - :done - promise that is delivered once receiving response has finished - :error - promise that is delivered if requesting resource failed, once delivered will contain Throwable. Arguments: - client - client created via create-client - url - URL to request - options - keyworded arguments: :query - map of query parameters, if value is vector than multiple values will be send as n=v1&n=v2 :headers - map of headers :body - body :cookies - cookies to send :proxy - map with proxy configuration to be used :host - proxy host :port - proxy port :protocol - (optional) protocol to communicate with proxy, :http (default, if you provide no value) and :https are allowed :user - (optional) user name to use for proxy authentication, has to be provided with :password :password - (optional) password to use for proxy authentication, has to be provided with :user :auth - map with authentication to be used :type - either :basic or :digest :user - user name to be used :password - password to be used :realm - realm name to authenticate in :timeout - request timeout in ms
(done? resp)
Checks if request is finished already (response receiving finished).
Checks if request is finished already (response receiving finished).
(error resp)
Returns Throwable if request processing failed.
Returns Throwable if request processing failed.
(GET client url & {:as options})
Sends asynchronously HTTP GET request to url. Returns a map:
Sends asynchronously HTTP GET request to url. Returns a map: - :id - unique ID of request - :status - promise that once status is received is delivered, contains lazy map of: - :code - response code - :msg - response message - :protocol - protocol with version - :major - major version of protocol - :minor - minor version of protocol - :headers - promise that once headers are received is delivered, contains lazy map of: - :server - header names are keyworded, values stay not changed - :body - body of response, depends on request type, might be ByteArrayOutputStream or lazy sequence, use conveniece methods to extract it, like string - :done - promise that is delivered once receiving response has finished - :error - promise that is delivered if requesting resource failed, once delivered will contain Throwable. Arguments: - client - client created via create-client - url - URL to request - options - keyworded arguments: :query - map of query parameters, if value is vector than multiple values will be send as n=v1&n=v2 :headers - map of headers :body - body :cookies - cookies to send :proxy - map with proxy configuration to be used :host - proxy host :port - proxy port :protocol - (optional) protocol to communicate with proxy, :http (default, if you provide no value) and :https are allowed :user - (optional) user name to use for proxy authentication, has to be provided with :password :password - (optional) password to use for proxy authentication, has to be provided with :user :auth - map with authentication to be used :type - either :basic or :digest :user - user name to be used :password - password to be used :realm - realm name to authenticate in :timeout - request timeout in ms
(HEAD client url & {:as options})
Sends asynchronously HTTP HEAD request to url. Returns a map:
Sends asynchronously HTTP HEAD request to url. Returns a map: - :id - unique ID of request - :status - promise that once status is received is delivered, contains lazy map of: - :code - response code - :msg - response message - :protocol - protocol with version - :major - major version of protocol - :minor - minor version of protocol - :headers - promise that once headers are received is delivered, contains lazy map of: - :server - header names are keyworded, values stay not changed - :body - body of response, depends on request type, might be ByteArrayOutputStream or lazy sequence, use conveniece methods to extract it, like string - :done - promise that is delivered once receiving response has finished - :error - promise that is delivered if requesting resource failed, once delivered will contain Throwable. Arguments: - client - client created via create-client - url - URL to request - options - keyworded arguments: :query - map of query parameters, if value is vector than multiple values will be send as n=v1&n=v2 :headers - map of headers :body - body :cookies - cookies to send :proxy - map with proxy configuration to be used :host - proxy host :port - proxy port :protocol - (optional) protocol to communicate with proxy, :http (default, if you provide no value) and :https are allowed :user - (optional) user name to use for proxy authentication, has to be provided with :password :password - (optional) password to use for proxy authentication, has to be provided with :user :auth - map with authentication to be used :type - either :basic or :digest :user - user name to be used :password - password to be used :realm - realm name to authenticate in :timeout - request timeout in ms
(headers resp)
Gets headers. If headers have not yet been delivered and request hasn't failed waits for headers.
Gets headers. If headers have not yet been delivered and request hasn't failed waits for headers.
(-close this)
(-open? this)
(location resp)
Retrieves location of redirect.
Retrieves location of redirect.
(OPTIONS client url & {:as options})
Sends asynchronously HTTP OPTIONS request to url. Returns a map:
Sends asynchronously HTTP OPTIONS request to url. Returns a map: - :id - unique ID of request - :status - promise that once status is received is delivered, contains lazy map of: - :code - response code - :msg - response message - :protocol - protocol with version - :major - major version of protocol - :minor - minor version of protocol - :headers - promise that once headers are received is delivered, contains lazy map of: - :server - header names are keyworded, values stay not changed - :body - body of response, depends on request type, might be ByteArrayOutputStream or lazy sequence, use conveniece methods to extract it, like string - :done - promise that is delivered once receiving response has finished - :error - promise that is delivered if requesting resource failed, once delivered will contain Throwable. Arguments: - client - client created via create-client - url - URL to request - options - keyworded arguments: :query - map of query parameters, if value is vector than multiple values will be send as n=v1&n=v2 :headers - map of headers :body - body :cookies - cookies to send :proxy - map with proxy configuration to be used :host - proxy host :port - proxy port :protocol - (optional) protocol to communicate with proxy, :http (default, if you provide no value) and :https are allowed :user - (optional) user name to use for proxy authentication, has to be provided with :password :password - (optional) password to use for proxy authentication, has to be provided with :user :auth - map with authentication to be used :type - either :basic or :digest :user - user name to be used :password - password to be used :realm - realm name to authenticate in :timeout - request timeout in ms
(PATCH client url & {:as options})
Sends asynchronously HTTP PATCH request to url. Returns a map:
Sends asynchronously HTTP PATCH request to url. Returns a map: - :id - unique ID of request - :status - promise that once status is received is delivered, contains lazy map of: - :code - response code - :msg - response message - :protocol - protocol with version - :major - major version of protocol - :minor - minor version of protocol - :headers - promise that once headers are received is delivered, contains lazy map of: - :server - header names are keyworded, values stay not changed - :body - body of response, depends on request type, might be ByteArrayOutputStream or lazy sequence, use conveniece methods to extract it, like string - :done - promise that is delivered once receiving response has finished - :error - promise that is delivered if requesting resource failed, once delivered will contain Throwable. Arguments: - client - client created via create-client - url - URL to request - options - keyworded arguments: :query - map of query parameters, if value is vector than multiple values will be send as n=v1&n=v2 :headers - map of headers :body - body :cookies - cookies to send :proxy - map with proxy configuration to be used :host - proxy host :port - proxy port :protocol - (optional) protocol to communicate with proxy, :http (default, if you provide no value) and :https are allowed :user - (optional) user name to use for proxy authentication, has to be provided with :password :password - (optional) password to use for proxy authentication, has to be provided with :user :auth - map with authentication to be used :type - either :basic or :digest :user - user name to be used :password - password to be used :realm - realm name to authenticate in :timeout - request timeout in ms
(POST client url & {:as options})
Sends asynchronously HTTP POST request to url. Returns a map:
Sends asynchronously HTTP POST request to url. Returns a map: - :id - unique ID of request - :status - promise that once status is received is delivered, contains lazy map of: - :code - response code - :msg - response message - :protocol - protocol with version - :major - major version of protocol - :minor - minor version of protocol - :headers - promise that once headers are received is delivered, contains lazy map of: - :server - header names are keyworded, values stay not changed - :body - body of response, depends on request type, might be ByteArrayOutputStream or lazy sequence, use conveniece methods to extract it, like string - :done - promise that is delivered once receiving response has finished - :error - promise that is delivered if requesting resource failed, once delivered will contain Throwable. Arguments: - client - client created via create-client - url - URL to request - options - keyworded arguments: :query - map of query parameters, if value is vector than multiple values will be send as n=v1&n=v2 :headers - map of headers :body - body :cookies - cookies to send :proxy - map with proxy configuration to be used :host - proxy host :port - proxy port :protocol - (optional) protocol to communicate with proxy, :http (default, if you provide no value) and :https are allowed :user - (optional) user name to use for proxy authentication, has to be provided with :password :password - (optional) password to use for proxy authentication, has to be provided with :user :auth - map with authentication to be used :type - either :basic or :digest :user - user name to be used :password - password to be used :realm - realm name to authenticate in :timeout - request timeout in ms
(PUT client url & {:as options})
Sends asynchronously HTTP PUT request to url. Returns a map:
Sends asynchronously HTTP PUT request to url. Returns a map: - :id - unique ID of request - :status - promise that once status is received is delivered, contains lazy map of: - :code - response code - :msg - response message - :protocol - protocol with version - :major - major version of protocol - :minor - minor version of protocol - :headers - promise that once headers are received is delivered, contains lazy map of: - :server - header names are keyworded, values stay not changed - :body - body of response, depends on request type, might be ByteArrayOutputStream or lazy sequence, use conveniece methods to extract it, like string - :done - promise that is delivered once receiving response has finished - :error - promise that is delivered if requesting resource failed, once delivered will contain Throwable. Arguments: - client - client created via create-client - url - URL to request - options - keyworded arguments: :query - map of query parameters, if value is vector than multiple values will be send as n=v1&n=v2 :headers - map of headers :body - body :cookies - cookies to send :proxy - map with proxy configuration to be used :host - proxy host :port - proxy port :protocol - (optional) protocol to communicate with proxy, :http (default, if you provide no value) and :https are allowed :user - (optional) user name to use for proxy authentication, has to be provided with :password :password - (optional) password to use for proxy authentication, has to be provided with :user :auth - map with authentication to be used :type - either :basic or :digest :user - user name to be used :password - password to be used :realm - realm name to authenticate in :timeout - request timeout in ms
(redirect? resp)
Checks if response is redirect.
Checks if response is redirect.
(request-stream client method url body-part-callback & {:as options})
Consumes stream from given url. method - HTTP method to be used (:get, :post, ...) url - URL to set request to body-part-callback - callback that takes status (ref {}) of request and received body part as vector of bytes options - are optional and can contain :headers, :param, and :query (see prepare-request).
Consumes stream from given url. method - HTTP method to be used (:get, :post, ...) url - URL to set request to body-part-callback - callback that takes status (ref {}) of request and received body part as vector of bytes options - are optional and can contain :headers, :param, and :query (see prepare-request).
(send ws & {text :text byte :byte})
Send message via WebSocket.
Send message via WebSocket.
(status resp)
Gets status if status was delivered.
Gets status if status was delivered.
(stream-seq client method url & {:as options})
Creates potentially infinite lazy sequence of Http Stream.
Creates potentially infinite lazy sequence of Http Stream.
(string resp)
(string headers body)
Converts response to string. Or converts body taking encoding from response.
Converts response to string. Or converts body taking encoding from response.
(uri resp)
Get the request URI from the response
Get the request URI from the response
(websocket client url & options)
Opens WebSocket connection.
Opens WebSocket connection.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close