Batteries-included HTTP client.
Batteries-included HTTP client.
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.
(accept-encoding-value accept-encoding)
(basic-auth-value basic-auth)
(check-url! url)
(client-error? {:keys [status]})
(coerce-clojure-body _request {:keys [body] :as resp})
(coerce-form-urlencoded-body _request {:keys [body] :as resp})
(coerce-json-body request {:keys [body] :as resp} keyword? & [charset])
(coerce-transit-body {:keys [transit-opts] :as request}
{:keys [body] :as resp}
type
&
[charset])
(conflict? {:keys [status]})
(content-type-value type)
(copy url & [req & r])
Like #'request, but sets the :method and :url as appropriate.
Like #'request, but sets the :method and :url as appropriate.
The default list of middleware clj-http uses for wrapping requests.
The default list of middleware clj-http uses for wrapping requests.
(delete url & [req & r])
Like #'request, but sets the :method and :url as appropriate.
Like #'request, but sets the :method and :url as appropriate.
(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.
(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.
(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.
(form-decode & args)
Resolve and apply ring-codec's form decoding dynamically.
Resolve and apply ring-codec's form decoding dynamically.
(generate-query-string params & [content-type multi-param-style])
(generate-query-string-with-encoding params encoding multi-param-style)
(get url & [req & r])
Like #'request, but sets the :method and :url as appropriate.
Like #'request, but sets the :method and :url as appropriate.
(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.
(head url & [req & r])
Like #'request, but sets the :method and :url as appropriate.
Like #'request, but sets the :method and :url as appropriate.
(json-decode & args)
Resolve and apply cheshire's json decoding dynamically.
Resolve and apply cheshire's json decoding dynamically.
(json-encode & args)
Resolve and apply cheshire's json encoding dynamically.
Resolve and apply cheshire's json encoding dynamically.
(maybe-wrap-entity {:keys [entity-buffering]} entity)
Wrap an HttpEntity in a BufferedHttpEntity if warranted.
Wrap an HttpEntity in a BufferedHttpEntity if warranted.
(missing? {:keys [status]})
(move url & [req & r])
Like #'request, but sets the :method and :url as appropriate.
Like #'request, but sets the :method and :url as appropriate.
(options url & [req & r])
Like #'request, but sets the :method and :url as appropriate.
Like #'request, but sets the :method and :url as appropriate.
(parse-edn & args)
Resolve and apply tool.reader's EDN parsing.
Resolve and apply tool.reader's EDN parsing.
(parse-html & args)
Resolve and apply crouton's HTML parsing.
Resolve and apply crouton's HTML parsing.
(parse-transit in type & [opts])
Resolve and apply Transit's JSON/MessagePack decoding.
Resolve and apply Transit's JSON/MessagePack decoding.
(parse-url url)
Parse a URL string into a map of interesting parts.
Parse a URL string into a map of interesting parts.
(parse-user-info user-info)
(patch url & [req & r])
Like #'request, but sets the :method and :url as appropriate.
Like #'request, but sets the :method and :url as appropriate.
(post url & [req & r])
Like #'request, but sets the :method and :url as appropriate.
Like #'request, but sets the :method and :url as appropriate.
(put url & [req & r])
Like #'request, but sets the :method and :url as appropriate.
Like #'request, but sets the :method and :url as appropriate.
(redirect? {:keys [status]})
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:
The following keys make an async HTTP request, like ring's CPS handler.
The following additional behaviors are also automatically enabled:
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.
(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
(server-error? {:keys [status]})
(success? {:keys [status]})
(transit-encode out type & [opts])
Resolve and apply Transit's JSON/MessagePack encoding.
Resolve and apply Transit's JSON/MessagePack encoding.
(unexceptional-status-for-request? req status)
(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!
(update m k f & args)
(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.
(when-pos v)
(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 the
current-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.
(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.
(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.
(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.
(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>
(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.
(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
(wrap-basic-auth client)
Middleware converting the :basic-auth option into an Authorization header.
Middleware converting the :basic-auth option into an Authorization header.
(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.
(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.
(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.
(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.
(wrap-form-params client)
Middleware wrapping the submission or form parameters.
Middleware wrapping the submission or form parameters.
(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.
(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.
(wrap-method client)
Middleware converting the :method option into the :request-method option
Middleware converting the :method option into the :request-method option
(wrap-nested-params client)
Middleware wrapping nested parameters for query strings.
Middleware wrapping nested parameters for query strings.
(wrap-oauth client)
Middleware converting the :oauth-token option into an Authorization header.
Middleware converting the :oauth-token option into an Authorization header.
(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.
(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.
(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
(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
(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.
(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.
(wrap-url client)
Middleware wrapping request URL parsing.
Middleware wrapping request URL parsing.
(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
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close