Liking cljdoc? Tell your friends :D

aleph.http.client-middleware

This middleware is adapted from clj-http, whose license is amenable to this sort of copy/pastery

This middleware is adapted from clj-http, whose license is amenable to this sort of
copy/pastery
raw docstring

accept-encoding-valueclj

(accept-encoding-value accept-encoding)

(add-cookie-header cookie-store cookie-spec req)

basic-auth-valueclj

(basic-auth-value basic-auth)

Accept a String of the form "username:password" or a vector of 2 strings [username password], return a String with the basic auth header (see https://tools.ietf.org/html/rfc2617#page-5)

Accept a String of the form "username:password" or a vector of 2 strings [username password], return a String with the basic auth header (see https://tools.ietf.org/html/rfc2617#page-5)
raw docstring

client-error?clj

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

coerce-clojure-bodyclj

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

coerce-form-paramscljmultimethod


coerce-json-bodyclj

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

coerce-response-bodycljmultimethod


coerce-transit-bodyclj

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

conflict?clj

(conflict? {:keys [status]})

content-type-valueclj

(content-type-value type)

(cookie->netty-cookie {:keys [domain http-only? secure? max-age name path
                              value]})

(cookie-expired? {:keys [created max-age]})


CookieSpeccljprotocol

Implement rules for accepting and returning cookies

Implement rules for accepting and returning cookies

match-cookie-origin?clj

(match-cookie-origin? this origin cookie)

parse-cookieclj

(parse-cookie this cookie-str)

write-cookiesclj

(write-cookies this cookies)
raw docstring

CookieStorecljprotocol

add-cookies!clj

(add-cookies! this cookies)

get-cookiesclj

(get-cookies this)

(decode-set-cookie-header header)
(decode-set-cookie-header cookie-spec header)

Default cookie spec implementation providing RFC6265 compliant behavior with no validation for cookie names and values. In case you need strict validation feel free to create impl. using {ClientCookieDecoder,ClientCookiEncoder}/STRICT instead of LAX instances

Default cookie spec implementation providing RFC6265 compliant behavior
with no validation for cookie names and values. In case you need strict validation
feel free to create impl. using {ClientCookieDecoder,ClientCookiEncoder}/STRICT
instead of LAX instances
raw docstring

default-middlewareclj


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

enrich-with-current-timeclj

(enrich-with-current-time cookies)

extract-cookies-from-response-headersclj

(extract-cookies-from-response-headers headers)
(extract-cookies-from-response-headers cookie-spec headers)

follow-redirectclj

(follow-redirect client
                 {:keys [uri url scheme server-name server-port trace-redirects]
                  :or {trace-redirects []}
                  :as req}
                 {:keys [body] :as rsp})

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

generate-query-stringclj

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

generate-query-string-with-encodingclj

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

handle-cookiesclj

(handle-cookies {:keys [cookie-store cookie-spec]
                 :or {cookie-spec default-cookie-spec}}
                {:keys [headers] :as rsp})

handle-redirectsclj

(handle-redirects client
                  {:keys [request-method max-redirects redirects-count
                          trace-redirects url]
                   :or {redirects-count 0 max-redirects 20}
                   :as req}
                  {:keys [status] :as rsp})

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

handle-response-debugclj

(handle-response-debug req rsp)

(in-memory-cookie-store)
(in-memory-cookie-store seed-cookies)

In-memory storage to maintain cookies across requests

In-memory storage to maintain cookies across requests
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-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).
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

(match-cookie-domain? origin domain)

(match-cookie-path? origin-path cookie-path)

merge-cookiesclj

(merge-cookies stored-cookies new-cookies)

missing?clj

(missing? {:keys [status]})

multi-param-suffixclj

(multi-param-suffix index multi-param-style)

(netty-cookie->cookie cookie)

optclj

(opt req param)

Check the request parameters for a keyword boolean option, with or without the ?

Returns false if either of the values are false, or the value of (or key1 key2) otherwise (truthy)

Check the request parameters for a keyword  boolean option, with or without
the ?

Returns false if either of the values are false, or the value of
(or key1 key2) otherwise (truthy)
raw docstring

parse-content-typeclj

(parse-content-type s)

Parse s as an RFC 2616 media type.

Parse `s` as an RFC 2616 media type.
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)

redirect?clj

(redirect? {:keys [status]})

(reduce-to-unique-cookie-names cookies)

req->cookie-originclj

(req->cookie-origin {:keys [url] :as req})

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


url-encodeclj

(url-encode s)
(url-encode s encoding)

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)

wrap-acceptclj

(wrap-accept {:keys [accept] :as req})

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 {:keys [accept-encoding] :as req})

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

(wrap-basic-auth req)

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 {:keys [content-type character-encoding] :as req})

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

(wrap-cookies {:keys [cookie-store cookie-spec cookies]
               :or {cookie-spec default-cookie-spec cookies (quote ())}
               :as req})

Middleware that set 'Cookie' header based on the content of cookies passed with the request or from cookies storage (when provided). Source for 'Cookie' header content by priorities:

  • 'Cookie' header (already set)
  • non-empty :cookies
  • non-nil :cookie-store

Each cookie should be represented as a map:

|:---|:--- | name | name of this cookie | value | value of this cookie | domain | specifies allowed hosts to receive the cookie (including subdomains) | path | indicates a URL path that must exist in the requested URL in order to send the 'Cookie' header | http-only? | when set to true, cookie can only be accessed by HTTP. Optional, defaults to false | secure? | when set to true, cookie can only be transmitted over an encrypted connection. Optional, defaults to false | max-age | set maximum age of this cookie in seconds. Options, defaults to io.netty.handler.codec.http.cookie.Cookie/UNDEFINED_MAX_AGE.

Middleware that set 'Cookie' header based on the content of cookies passed
with the request or from cookies storage (when provided). Source for 'Cookie'
header content by priorities:

* 'Cookie' header (already set)
* non-empty `:cookies`
* non-nil `:cookie-store`

Each cookie should be represented as a map:

|:---|:---
| `name` | name of this cookie
| `value` | value of this cookie
| `domain` | specifies allowed hosts to receive the cookie (including subdomains)
| `path` | indicates a URL path that must exist in the requested URL in order to send the 'Cookie' header
| `http-only?` | when set to `true`, cookie can only be accessed by HTTP. Optional, defaults to `false`
| `secure?` | when set to `true`, cookie can only be transmitted over an encrypted connection. Optional, defaults to `false`
| `max-age` | set maximum age of this cookie in seconds. Options, defaults to `io.netty.handler.codec.http.cookie.Cookie/UNDEFINED_MAX_AGE`.
raw docstring

wrap-exceptionsclj

(wrap-exceptions client)

Middleware that throws response as an ExceptionInfo if the response has unsuccessful status code. :throw-exceptions set to false in the request disables this middleware.

Middleware that throws response as an ExceptionInfo if the response has
unsuccessful status code. :throw-exceptions set to false in the request
disables this middleware.
raw docstring

wrap-form-paramsclj

(wrap-form-params {:keys [form-params content-type request-method]
                   :or {content-type :x-www-form-urlencoded}
                   :as req})

Middleware wrapping the submission or form parameters.

Middleware wrapping the submission or form parameters.
raw docstring

wrap-methodclj

(wrap-method req)

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 {:keys [content-type flatten-nested-keys] :as req})

Middleware wrapping nested parameters for query strings.

Middleware wrapping nested parameters for query strings.
raw docstring

wrap-oauthclj

(wrap-oauth req)

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

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

wrap-query-paramsclj

(wrap-query-params {:keys [query-params content-type multi-param-style]
                    :or {content-type :x-www-form-urlencoded
                         multi-param-style :default}
                    :as req})

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

(wrap-request client)

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

(wrap-request-debug req)

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

(wrap-url req)

Middleware wrapping request URL parsing.

Middleware wrapping request URL parsing.
raw docstring

wrap-user-infoclj

(wrap-user-info req)

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

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

(write-cookie-header cookies cookie-spec req)

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

× close