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.
sourceraw docstring

accept-encoding-valueclj

(accept-encoding-value accept-encoding)
source

basic-auth-valueclj

(basic-auth-value basic-auth)
source

check-url!clj

(check-url! url)
source

client-error?clj

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

coerce-clojure-bodyclj

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

coerce-content-typecljmultimethod

source

coerce-form-paramscljmultimethod

source

coerce-form-urlencoded-bodyclj

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

coerce-json-bodyclj

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

coerce-response-bodycljmultimethod

source

coerce-transit-bodyclj

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

conflict?clj

(conflict? {:keys [status]})
source

content-type-valueclj

(content-type-value type)
source

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.
sourceraw docstring

crouton-enabled?clj

source

decompress-bodycljmultimethod

source

default-middlewareclj

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

The default list of middleware clj-http uses for wrapping requests.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw docstring

edn-enabled?clj

source

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.
sourceraw docstring

form-decodeclj

(form-decode & args)

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

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

generate-query-stringclj

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

generate-query-string-with-encodingclj

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

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.
sourceraw 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.
sourceraw 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.
sourceraw docstring

json-decodeclj

(json-decode & args)

Resolve and apply cheshire's json decoding dynamically.

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

json-decode-strictclj

(json-decode-strict & args)

Resolve and apply cheshire's json decoding dynamically (with lazy parsing disabled).

Resolve and apply cheshire's json decoding dynamically (with lazy parsing
disabled).
sourceraw docstring

json-enabled?clj

source

json-encodeclj

(json-encode & args)

Resolve and apply cheshire's json encoding dynamically.

Resolve and apply cheshire's json encoding dynamically.
sourceraw 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.
sourceraw docstring

missing?clj

(missing? {:keys [status]})
source

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.
sourceraw 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.
sourceraw docstring

parse-ednclj

(parse-edn & args)

Resolve and apply tool.reader's EDN parsing.

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

parse-htmlclj

(parse-html & args)

Resolve and apply crouton's HTML parsing.

Resolve and apply crouton's HTML parsing.
sourceraw docstring

parse-transitclj

(parse-transit in type & [opts])

Resolve and apply Transit's JSON/MessagePack decoding.

Resolve and apply Transit's JSON/MessagePack decoding.
sourceraw 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.
sourceraw docstring

parse-user-infoclj

(parse-user-info user-info)
source

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.
sourceraw 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.
sourceraw 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.
sourceraw docstring

redirect?clj

(redirect? {:keys [status]})
source

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.
sourceraw 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
sourceraw docstring

ring-codec-enabled?clj

source

server-error?clj

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

success?clj

(success? {:keys [status]})
source

transit-enabled?clj

source

transit-encodeclj

(transit-encode out type & [opts])

Resolve and apply Transit's JSON/MessagePack encoding.

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

unexceptional-status-for-request?clj

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

unexceptional-status?clj

source

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!
sourceraw docstring

updateclj

(update m k f & args)
source

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.
sourceraw docstring

when-posclj

(when-pos v)
source

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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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>
sourceraw 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.
sourceraw 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
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw docstring

wrap-form-paramsclj

(wrap-form-params client)

Middleware wrapping the submission or form parameters.

Middleware wrapping the submission or form parameters.
sourceraw 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.
sourceraw 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.
sourceraw 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
sourceraw docstring

wrap-nested-paramsclj

(wrap-nested-params client)

Middleware wrapping nested parameters for query strings.

Middleware wrapping nested parameters for query strings.
sourceraw 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.
sourceraw 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.
sourceraw 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.
sourceraw 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
sourceraw 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
sourceraw 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.
sourceraw 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.
sourceraw docstring

wrap-urlclj

(wrap-url client)

Middleware wrapping request URL parsing.

Middleware wrapping request URL parsing.
sourceraw 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
sourceraw docstring

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

× close