Liking cljdoc? Tell your friends :D

clj-http.client

Batteries-included HTTP client.

Batteries-included HTTP client.
raw docstring

*current-middleware*clj

Available at any time to retrieve the middleware being used. Automatically bound when with-middleware is used.

Available at any time to retrieve the middleware being used.
Automatically bound when `with-middleware` is used.
raw docstring

accept-encoding-valueclj

(accept-encoding-value accept-encoding)

basic-auth-valueclj

(basic-auth-value basic-auth)

check-url!clj

(check-url! url)

client-error?clj

(client-error? {:keys [status]})

coerce-clojure-bodyclj

(coerce-clojure-body _request {:keys [body] :as resp})

coerce-content-typecljmultimethod


coerce-form-paramscljmultimethod


coerce-form-urlencoded-bodyclj

(coerce-form-urlencoded-body _request {:keys [body] :as resp})

coerce-json-bodyclj

(coerce-json-body request {:keys [body] :as resp} keyword? & [charset])

coerce-response-bodycljmultimethod


coerce-transit-bodyclj

(coerce-transit-body {:keys [transit-opts] :as request}
                     {:keys [body] :as resp}
                     type
                     &
                     [charset])

conflict?clj

(conflict? {:keys [status]})

content-type-valueclj

(content-type-value type)

copyclj

(copy url & [req & r])

Like #'request, but sets the :method and :url as appropriate.

Like #'request, but sets the :method and :url as appropriate.
raw docstring

crouton-enabled?clj


decompress-bodycljmultimethod


default-middlewareclj

The default list of middleware clj-http uses for wrapping requests.

The default list of middleware clj-http uses for wrapping requests.
raw docstring

deleteclj

(delete url & [req & r])

Like #'request, but sets the :method and :url as appropriate.

Like #'request, but sets the :method and :url as appropriate.
raw docstring

detect-charsetclj

(detect-charset content-type)

Given a charset header, detect the charset, returns UTF-8 if not found.

Given a charset header, detect the charset, returns UTF-8 if not found.
raw docstring

dissoc-inclj

(dissoc-in m [k & ks :as keys])

Dissociates an entry from a nested associative structure returning a new nested structure. keys is a sequence of keys. Any empty maps that result will not be present in the new structure.

Dissociates an entry from a nested associative structure returning a new
nested structure. keys is a sequence of keys. Any empty maps that result
will not be present in the new structure.
raw docstring

edn-enabled?clj


follow-redirectclj

(follow-redirect
  client
  {:keys [uri url scheme server-name server-port async? respond raise] :as req}
  {:keys [trace-redirects body] :as resp})

Attempts to follow the redirects from the "location" header, if no such header exists (bad server!), returns the response without following the request.

Attempts to follow the redirects from the "location" header, if no such
header exists (bad server!), returns the response without following the
request.
raw docstring

form-decodeclj

(form-decode & args)

Resolve and apply ring-codec's form decoding dynamically.

Resolve and apply ring-codec's form decoding dynamically.
raw docstring

generate-query-stringclj

(generate-query-string params & [content-type multi-param-style])

generate-query-string-with-encodingclj

(generate-query-string-with-encoding params encoding multi-param-style)

getclj

(get url & [req & r])

Like #'request, but sets the :method and :url as appropriate.

Like #'request, but sets the :method and :url as appropriate.
raw docstring

get-headers-from-bodyclj

(get-headers-from-body body-map)

Given a map of body content, return a map of header-name to header-value.

Given a map of body content, return a map of header-name to header-value.
raw docstring

(head url & [req & r])

Like #'request, but sets the :method and :url as appropriate.

Like #'request, but sets the :method and :url as appropriate.
raw docstring

json-decodeclj

(json-decode & args)

Resolve and apply cheshire's json decoding dynamically.

Resolve and apply cheshire's json decoding dynamically.
raw docstring

json-enabled?clj


json-encodeclj

(json-encode & args)

Resolve and apply cheshire's json encoding dynamically.

Resolve and apply cheshire's json encoding dynamically.
raw docstring

maybe-wrap-entityclj

(maybe-wrap-entity {:keys [entity-buffering]} entity)

Wrap an HttpEntity in a BufferedHttpEntity if warranted.

Wrap an HttpEntity in a BufferedHttpEntity if warranted.
raw docstring

missing?clj

(missing? {:keys [status]})

moveclj

(move url & [req & r])

Like #'request, but sets the :method and :url as appropriate.

Like #'request, but sets the :method and :url as appropriate.
raw docstring

optionsclj

(options url & [req & r])

Like #'request, but sets the :method and :url as appropriate.

Like #'request, but sets the :method and :url as appropriate.
raw docstring

parse-ednclj

(parse-edn & args)

Resolve and apply tool.reader's EDN parsing.

Resolve and apply tool.reader's EDN parsing.
raw docstring

parse-htmlclj

(parse-html & args)

Resolve and apply crouton's HTML parsing.

Resolve and apply crouton's HTML parsing.
raw docstring

parse-transitclj

(parse-transit in type & [opts])

Resolve and apply Transit's JSON/MessagePack decoding.

Resolve and apply Transit's JSON/MessagePack decoding.
raw docstring

parse-urlclj

(parse-url url)

Parse a URL string into a map of interesting parts.

Parse a URL string into a map of interesting parts.
raw docstring

parse-user-infoclj

(parse-user-info user-info)

patchclj

(patch url & [req & r])

Like #'request, but sets the :method and :url as appropriate.

Like #'request, but sets the :method and :url as appropriate.
raw docstring

postclj

(post url & [req & r])

Like #'request, but sets the :method and :url as appropriate.

Like #'request, but sets the :method and :url as appropriate.
raw docstring

putclj

(put url & [req & r])

Like #'request, but sets the :method and :url as appropriate.

Like #'request, but sets the :method and :url as appropriate.
raw docstring

redirect?clj

(redirect? {:keys [status]})

requestclj

Executes the HTTP request corresponding to the given map and returns the response map for corresponding to the resulting HTTP response.

In addition to the standard Ring request keys, the following keys are also recognized:

  • :url
  • :method
  • :query-params
  • :basic-auth
  • :content-type
  • :accept
  • :accept-encoding
  • :as

The following keys make an async HTTP request, like ring's CPS handler.

  • :async?
  • :respond
  • :raise

The following additional behaviors are also automatically enabled:

  • Exceptions are thrown for status codes other than 200-207, 300-303, or 307
  • Gzip and deflate responses are accepted and decompressed
  • Input and output bodies are coerced as required and indicated by the :as option.
Executes the HTTP request corresponding to the given map and returns
the response map for corresponding to the resulting HTTP response.

In addition to the standard Ring request keys, the following keys are also
recognized:
* :url
* :method
* :query-params
* :basic-auth
* :content-type
* :accept
* :accept-encoding
* :as

The following keys make an async HTTP request, like ring's CPS handler.
* :async?
* :respond
* :raise

The following additional behaviors are also automatically enabled:
* Exceptions are thrown for status codes other than 200-207, 300-303, or 307
* Gzip and deflate responses are accepted and decompressed
* Input and output bodies are coerced as required and indicated by the :as
option.
raw docstring

reuse-poolclj

(reuse-pool options response)

A helper function takes a request options map and a response map respond from a pooled async request, the returned options map will be set to reuse the connection pool which used by the former request

A helper function takes a request options map and a response map respond
from a pooled async request, the returned options map will be set to reuse
the connection pool which used by the former request
raw docstring

ring-codec-enabled?clj


server-error?clj

(server-error? {:keys [status]})

success?clj

(success? {:keys [status]})

transit-enabled?clj


transit-encodeclj

(transit-encode out type & [opts])

Resolve and apply Transit's JSON/MessagePack encoding.

Resolve and apply Transit's JSON/MessagePack encoding.
raw docstring

unexceptional-status-for-request?clj

(unexceptional-status-for-request? req status)

unexceptional-status?clj


unparse-urlclj

(unparse-url {:keys [scheme server-name server-port uri user-info
                     query-string]})

Takes a map of url-parts and generates a string representation. WARNING: does not do any sort of encoding! Don't use this for strict RFC following!

Takes a map of url-parts and generates a string representation.
WARNING: does not do any sort of encoding! Don't use this for strict RFC
following!
raw docstring

updateclj

(update m k f & args)

url-encode-illegal-charactersclj

(url-encode-illegal-characters path-or-query)

Takes a raw url path or query and url-encodes any illegal characters. Minimizes ambiguity by encoding space to %20.

Takes a raw url path or query and url-encodes any illegal characters.
Minimizes ambiguity by encoding space to %20.
raw docstring

when-posclj

(when-pos v)

with-additional-middlewarecljmacro

(with-additional-middleware middleware-seq & body)

Perform the body of the macro with a list of additional middleware.

The given middleware-seq' is concatenated to the beginning of thecurrent-middleware' sequence.

Perform the body of the macro with a list of additional middleware.

The given `middleware-seq' is concatenated to the beginning of the
`*current-middleware*' sequence.
raw docstring

with-async-connection-poolcljmacro

(with-async-connection-pool opts & body)

Macro to execute the body using a connection manager. Creates a PoolingNHttpClientConnectionManager to use for all requests within the body of the expression. An option map is allowed to set options for the connection manager.

Handles the same options as with-connection-pool plus: :io-config which should be a map containing some of the following keys:

:connect-timeout - int the default connect timeout value for connection requests (default 0, meaning no timeout) :interest-op-queued - boolean, whether or not I/O interest operations are to be queued and executed asynchronously or to be applied to the underlying SelectionKey immediately (default false) :io-thread-count - int, the number of I/O dispatch threads to be used (default is the number of available processors) :rcv-buf-size - int the default value of the SO_RCVBUF parameter for newly created sockets (default is 0, meaning the system default) :select-interval - long, time interval in milliseconds at which to check for timed out sessions and session requests (default 1000) :shutdown-grace-period - long, grace period in milliseconds to wait for individual worker threads to terminate cleanly (default 500) :snd-buf-size - int, the default value of the SO_SNDBUF parameter for newly created sockets (default is 0, meaning the system default) :so-keep-alive - boolean, the default value of the SO_KEEPALIVE parameter for newly created sockets (default false) :so-linger - int, the default value of the SO_LINGER parameter for newly created sockets (default -1) :so-timeout - int, the default socket timeout value for I/O operations (default 0, meaning no timeout) :tcp-no-delay - boolean, the default value of the TCP_NODELAY parameter for newly created sockets (default true)

If the value 'nil' is specified or the value is not set, the default value will be used.

Macro to execute the body using a connection manager. Creates a
PoolingNHttpClientConnectionManager to use for all requests within the body of
the expression. An option map is allowed to set options for the connection
manager.

Handles the same options as `with-connection-pool` plus:
:io-config which should be a map containing some of the following keys:

:connect-timeout - int the default connect timeout value for connection
  requests (default 0, meaning no timeout)
:interest-op-queued - boolean, whether or not I/O interest operations are to
  be queued and executed asynchronously or to be applied to the underlying
  SelectionKey immediately (default false)
:io-thread-count - int, the number of I/O dispatch threads to be used
  (default is the number of available processors)
:rcv-buf-size - int the default value of the SO_RCVBUF parameter for
  newly created sockets (default is 0, meaning the system default)
:select-interval - long, time interval in milliseconds at which to check for
  timed out sessions and session requests (default 1000)
:shutdown-grace-period - long, grace period in milliseconds to wait for
  individual worker threads to terminate cleanly (default 500)
:snd-buf-size - int, the default value of the SO_SNDBUF parameter for
  newly created sockets (default is 0, meaning the system default)
:so-keep-alive - boolean, the default value of the SO_KEEPALIVE parameter for
  newly created sockets (default false)
:so-linger - int, the default value of the SO_LINGER parameter for
  newly created sockets (default -1)
:so-timeout - int, the default socket timeout value for I/O operations
  (default 0, meaning no timeout)
:tcp-no-delay - boolean, the default value of the TCP_NODELAY parameter for
  newly created sockets (default true)

If the value 'nil' is specified or the value is not set, the default value
will be used.
raw docstring

with-connection-poolcljmacro

(with-connection-pool opts & body)

Macro to execute the body using a connection manager. Creates a PoolingHttpClientConnectionManager to use for all requests within the body of the expression. An option map is allowed to set options for the connection manager.

The following options are supported:

:timeout - Time that connections are left open before automatically closing default: 5 :threads - Maximum number of threads that will be used for connecting default: 4 :default-per-route - Maximum number of simultaneous connections per host default: 2 :insecure? - Boolean flag to specify allowing insecure HTTPS connections default: false

:keystore - keystore file path or KeyStore instance to be used for connection manager :keystore-pass - keystore password :trust-store - trust store file path or KeyStore instance to be used for connection manager :trust-store-pass - trust store password

Note that :insecure? and :keystore/:trust-store options are mutually exclusive

If the value 'nil' is specified or the value is not set, the default value will be used.

Macro to execute the body using a connection manager. Creates a
PoolingHttpClientConnectionManager to use for all requests within the
body of the expression. An option map is allowed to set options for the
connection manager.

The following options are supported:

:timeout - Time that connections are left open before automatically closing
default: 5
:threads - Maximum number of threads that will be used for connecting
default: 4
:default-per-route - Maximum number of simultaneous connections per host
default: 2
:insecure? - Boolean flag to specify allowing insecure HTTPS connections
default: false

:keystore - keystore file path or KeyStore instance to be used for
connection manager
:keystore-pass - keystore password
:trust-store - trust store file path or KeyStore instance to be used for
connection manager
:trust-store-pass - trust store password

Note that :insecure? and :keystore/:trust-store options are mutually exclusive

If the value 'nil' is specified or the value is not set, the default value
will be used.
raw docstring

with-middlewarecljmacro

(with-middleware middleware & body)

Perform the body of the macro with a custom middleware list.

It is highly recommended to at least include: clj-http.client/wrap-url clj-http.client/wrap-method

Unless you really know what you are doing.

Perform the body of the macro with a custom middleware list.

It is highly recommended to at least include:
clj-http.client/wrap-url
clj-http.client/wrap-method

Unless you really know what you are doing.
raw docstring

wrap-acceptclj

(wrap-accept client)

Middleware converting the :accept key in a request to application/<type>

Middleware converting the :accept key in a request to application/<type>
raw docstring

wrap-accept-encodingclj

(wrap-accept-encoding client)

Middleware converting the :accept-encoding option to an acceptable Accept-Encoding header in the request.

Middleware converting the :accept-encoding option to an acceptable
Accept-Encoding header in the request.
raw docstring

wrap-additional-header-parsingclj

(wrap-additional-header-parsing client)

Middleware that parses additional http headers from the body of a web page, adding them into the headers map of the response if any are found. Only looks at the body if the :decode-body-headers option is set to a truthy value. Will be silently disabled if crouton is excluded from clj-http's dependencies. Will do nothing if no body is returned, e.g. HEAD requests

Middleware that parses additional http headers from the body of a web page,
adding them into the headers map of the response if any are found. Only looks
at the body if the :decode-body-headers option is set to a truthy value. Will
be silently disabled if crouton is excluded from clj-http's dependencies. Will
do nothing if no body is returned, e.g. HEAD requests
raw docstring

wrap-basic-authclj

(wrap-basic-auth client)

Middleware converting the :basic-auth option into an Authorization header.

Middleware converting the :basic-auth option into an Authorization header.
raw docstring

wrap-content-typeclj

(wrap-content-type client)

Middleware converting a :content-type <keyword> option to the formal application/<name> format and adding it as a header.

Middleware converting a `:content-type <keyword>` option to the formal
application/<name> format and adding it as a header.
raw docstring

wrap-decompressionclj

(wrap-decompression client)

Middleware handling automatic decompression of responses from web servers. If :decompress-body is set to false, does not automatically set Accept-Encoding header or decompress body.

Middleware handling automatic decompression of responses from web servers. If
:decompress-body is set to false, does not automatically set `Accept-Encoding`
header or decompress body.
raw docstring

wrap-exceptionsclj

(wrap-exceptions client)

Middleware that throws a slingshot exception if the response is not a regular response. If :throw-entire-message? is set to true, the entire response is used as the message, instead of just the status number.

Middleware that throws a slingshot exception if the response is not a
regular response. If :throw-entire-message? is set to true, the entire
response is used as the message, instead of just the status number.
raw docstring

wrap-flatten-nested-paramsclj

(wrap-flatten-nested-params client)

Middleware wrapping options for whether or not to flatten :query-params and :form-params. Modifies the request by adding a :flatten-nested-keys sequence of the nested keys that will be flattened.

Middleware wrapping options for whether or not to flatten `:query-params` and
`:form-params`. Modifies the request by adding a `:flatten-nested-keys`
sequence of the nested keys that will be flattened.
raw docstring

wrap-form-paramsclj

(wrap-form-params client)

Middleware wrapping the submission or form parameters.

Middleware wrapping the submission or form parameters.
raw docstring

wrap-input-coercionclj

(wrap-input-coercion client)

Middleware coercing the :body of a request from a number of formats into an Apache Entity. Currently supports Strings, Files, InputStreams and byte-arrays.

Middleware coercing the :body of a request from a number of formats into an
Apache Entity. Currently supports Strings, Files, InputStreams
and byte-arrays.
raw docstring

wrap-lower-case-headersclj

(wrap-lower-case-headers client)

Middleware lowercasing all headers, as per RFC (case-insensitive) and Ring spec.

Middleware lowercasing all headers, as per RFC (case-insensitive) and
Ring spec.
raw docstring

wrap-methodclj

(wrap-method client)

Middleware converting the :method option into the :request-method option

Middleware converting the :method option into the :request-method option
raw docstring

wrap-nested-paramsclj

(wrap-nested-params client)

Middleware wrapping nested parameters for query strings.

Middleware wrapping nested parameters for query strings.
raw docstring

wrap-oauthclj

(wrap-oauth client)

Middleware converting the :oauth-token option into an Authorization header.

Middleware converting the :oauth-token option into an Authorization header.
raw docstring

wrap-output-coercionclj

(wrap-output-coercion client)

Middleware converting a response body from a byte-array to a different object. Defaults to a String if no :as key is specified, the coerce-response-body multimethod may be extended to add additional coercions.

Middleware converting a response body from a byte-array to a different
object. Defaults to a String if no :as key is specified, the
`coerce-response-body` multimethod may be extended to add
additional coercions.
raw docstring

wrap-query-paramsclj

(wrap-query-params client)

Middleware converting the :query-params option to a querystring on the request.

Middleware converting the :query-params option to a querystring on
the request.
raw docstring

wrap-redirectscljdeprecated

(wrap-redirects client)

Middleware that follows redirects in the response. A slingshot exception is thrown if too many redirects occur. Options

:follow-redirects - default:true, whether to follow redirects :max-redirects - default:20, maximum number of redirects to follow :force-redirects - default:false, force redirecting methods to GET requests

In the response:

:redirects-count - number of redirects :trace-redirects - vector of sites the request was redirected from

Middleware that follows redirects in the response. A slingshot exception is
thrown if too many redirects occur. Options

:follow-redirects - default:true, whether to follow redirects
:max-redirects - default:20, maximum number of redirects to follow
:force-redirects - default:false, force redirecting methods to GET requests

In the response:

:redirects-count - number of redirects
:trace-redirects - vector of sites the request was redirected from
raw docstring

wrap-requestclj

(wrap-request request)

Returns a batteries-included HTTP request function corresponding to the given core client. See default-middleware for the middleware wrappers that are used by default

Returns a batteries-included HTTP request function corresponding to the given
core client. See default-middleware for the middleware wrappers that are used
by default
raw docstring

wrap-request-timingclj

(wrap-request-timing client)

Middleware that times the request, putting the total time (in milliseconds) of the request into the :request-time key in the response.

Middleware that times the request, putting the total time (in milliseconds)
of the request into the :request-time key in the response.
raw docstring

wrap-unknown-hostclj

(wrap-unknown-host client)

Middleware ignoring unknown hosts when the :ignore-unknown-host? option is set.

Middleware ignoring unknown hosts when the :ignore-unknown-host? option
is set.
raw docstring

wrap-urlclj

(wrap-url client)

Middleware wrapping request URL parsing.

Middleware wrapping request URL parsing.
raw docstring

wrap-user-infoclj

(wrap-user-info client)

Middleware converting the :user-info option into a :basic-auth option

Middleware converting the :user-info option into a :basic-auth option
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close