Liking cljdoc? Tell your friends :D

clj-http.lite.client

Batteries-included HTTP client.

Among the many functions here you'll likely be most interested in get head put post delete or the slightly lower level request.

Batteries-included HTTP client.

Among the many functions here you'll likely be most interested in
[[get]] [[head]] [[put]] [[post]] [[delete]] or the slightly lower level [[request]].
raw docstring

accept-encoding-valueclj

(accept-encoding-value accept-encoding)
source

basic-auth-valueclj

(basic-auth-value basic-auth)
source

content-type-valueclj

(content-type-value type)
source

deleteclj

(delete url & [req])

Executes HTTP DELETE request for url and, optionally, more req attributes. See request.

Executes HTTP DELETE request for `url` and, optionally, more `req` attributes.
See [[request]].
sourceraw docstring

follow-redirectclj

(follow-redirect client req resp)
source

generate-query-stringclj

(generate-query-string params)
source

getclj

(get url & [req])

Executes HTTP GET request for url and, optionally, more req attributes. See request.

Executes HTTP GET request for `url` and, optionally, more `req` attributes.
See [[request]].
sourceraw docstring

(head url & [req])

Executes HTTP HEAD request for url and, optionally, more req attributes. See request.

Executes HTTP HEAD request for `url` and, optionally, more `req` attributes.
See [[request]].
sourceraw docstring

parse-urlclj

(parse-url url)
source

parse-user-infoclj

(parse-user-info user-info)
source

postclj

(post url & [req])

Executes HTTP POST request for url and, optionally, more req attributes. See request.

Executes HTTP POST request for `url` and, optionally, more `req` attributes.
See [[request]].
sourceraw docstring

putclj

(put url & [req])

Executes HTTP PUT request for url and, optionally, more req attributes. See request.

Executes HTTP PUT request for `url` and, optionally, more `req` attributes.
See [[request]].
sourceraw docstring

requestclj

(request req)

Returns response map for executed HTTP req map.

Notice that some req key entries will be overwritten by automatic conversion to other key entries:

Request method

  • :method - ex. :get,:head,:post,:put,:delete, converts to :request-method with same value

Request URL

  • :url - ex. "https://joe:blow@example.com:443/some/path?q=clojure", converts to:
    • :scheme - protocol :https
    • :server-name - host "example.com"
    • :server-port - 443 (if not specified, will be inferred from :scheme)
    • :uri - path "/some/path"
    • :user-info - "joe:blow", converts to:
      • :basic-auth - which automatically converts to appropriate :headers
    • :query-string - "q=clojure"
  • :query-params - ex. {"q" "clojure"} or {:q "clojure"} converts to :query-string (see above)

Request body & headers

  • :body - can be a string, byte array, File or input stream
  • :body-encoding - charset ex. "UTF-16", defaults to "UTF-8", iff :body is string converts to:
    • :body encoded in charset
    • :character-encoding set to charset which converts to appropriate :headers iff :content-type also set
  • :content-type - media type of request body, converts to appropriate :headers entry, specify:
    • keyword as shorthand, ex. :json for "application/json"
    • string for verboten, ex. "text/html"
  • :form-params - ex. {"q" "clojure"} or {:q "clojure"}, iff :method is :post: converts to:
    • urlencoded :body
    • appropriate :headers entry
  • :oauth-token - bearer authorization token, ex. "my70k3nh3r3", converts to appropriate :headers entry
  • :basic-auth - basic authentication, converts to appropriate :headers entry, (see also :url and :user-info), specify:
    • vector ["uname" "pass"] becomes "uname:pass"
    • use string for verboten
  • :accept-encoding - vector of accepted response encodings, ex. [:gzip :deflate :identity], converts to appropriate :headers entry
  • :accept - accept response of media type, converts to appropriate :headers entry, specify
    • keyword as shorthand, ex. :json for "application/json"
    • string for verboten, ex. "text/html"
  • :headers - explicitly set request headers, ex. {"Cache-Control" "no-cache"}

Request behaviour

  • :as - specifies how response body should be coerced:
    • :stream
    • :byte-array
    • :auto - to string decoded with charset in response :headers content-type charset else UTF-8
    • "charset" - to string decoded with charset ex. "utf-16"
    • else - to string decoded with UTF-8
  • :follow-redirects - specify false to not follow response redirects
  • :throw-exceptions - specify false to not throw on https status error codes
  • :ignore-unknown-host? - specify true to not throw on unknown host
  • :insecure? - allow connection with an invalid SSL certificate
  • :conn-timeout - number of milliseconds to wait to establish a connection
  • :socket-timeout - number of milliseconds to wait for data to be available to read
  • :save-request? - specify true to include ultimate converted :request used in response map
  • :chunk-size - in bytes, enables streaming of HTTP request body with chunk-size bytes, see JDK docs for details

Response map keys:

  • :status - http status code, see :throw-exceptions above
  • :headers - response headers
  • :body - response body, gzip and deflate responses are accepted and decompressed. See :as above.
  • :request - see :save-request? above

See README for example usages.

Returns response map for executed HTTP `req` map.

   Notice that some `req` key entries will be overwritten by automatic conversion to other key entries:

   Request method
   * `:method` -  ex. `:get`,`:head`,`:post`,`:put`,`:delete`, converts to `:request-method` with same value

   Request URL
   * `:url` - ex. `"https://joe:blow@example.com:443/some/path?q=clojure"`, converts to:
     * `:scheme` - protocol `:https`
     * `:server-name` - host `"example.com"`
     * `:server-port` - `443` (if not specified, will be inferred from `:scheme`)
     * `:uri` - path `"/some/path"`
     * `:user-info` -  `"joe:blow"`, converts to:
       * `:basic-auth` - which automatically converts to appropriate `:headers`
     * `:query-string` - `"q=clojure"`
   * `:query-params` - ex. `{"q" "clojure"}` or `{:q "clojure"}` converts to `:query-string` (see above)

   Request body & headers
   * `:body` - can be a string, byte array, File or input stream
   * `:body-encoding` - charset ex. `"UTF-16"`, defaults to `"UTF-8"`, iff `:body` is string converts to:
      * `:body` encoded in charset
      * `:character-encoding` set to charset which converts to appropriate `:headers` iff `:content-type` also set
   * `:content-type` - media type of request body, converts to appropriate `:headers` entry, specify:
     * keyword as shorthand, ex. `:json` for `"application/json"`
     * string for verboten, ex. `"text/html"`
   * `:form-params` - ex. `{"q" "clojure"}` or `{:q "clojure"}`, iff `:method` is `:post`: converts to:
      * urlencoded `:body`
      * appropriate `:headers` entry
   * `:oauth-token` - bearer authorization token, ex. `"my70k3nh3r3"`, converts to appropriate `:headers` entry
   * `:basic-auth` - basic authentication, converts to appropriate `:headers` entry, (see also `:url` and `:user-info`), specify:
     * vector `["uname" "pass"]` becomes `"uname:pass"`
     * use string for verboten
   * `:accept-encoding` - vector of accepted response encodings, ex. `[:gzip :deflate :identity]`, converts to appropriate `:headers` entry
   * `:accept` - accept response of media type, converts to appropriate `:headers` entry, specify
     * keyword as shorthand, ex. `:json` for `"application/json"`
     * string for verboten, ex. `"text/html"`
   * `:headers` - explicitly set request headers, ex. `{"Cache-Control" "no-cache"}`

   Request behaviour
   * `:as` - specifies how response body should be coerced:
     * `:stream`
     * `:byte-array`
     * `:auto` - to string decoded with `charset` in response `:headers` `content-type` `charset` else UTF-8
     * `"charset"` - to string decoded with `charset` ex. `"utf-16"`
     * else - to string decoded with UTF-8
   * `:follow-redirects` - specify `false` to not follow response redirects
   * `:throw-exceptions` - specify `false` to not throw on https status error codes
   * `:ignore-unknown-host?` - specify `true` to not throw on unknown host
   * `:insecure?` - allow connection with an invalid SSL certificate
   * `:conn-timeout` - number of milliseconds to wait to establish a connection
   * `:socket-timeout` - number of milliseconds to wait for data to be available to read
   * `:save-request?` - specify `true` to include ultimate converted `:request` used in response map
   * `:chunk-size` - in bytes, enables streaming of HTTP request body with chunk-size bytes,
see [JDK docs](https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html#setChunkedStreamingMode-int-)
for details

  Response map keys:
  * `:status` - http status code, see `:throw-exceptions` above
  * `:headers` - response headers
  * `:body` - response body, gzip and deflate responses are accepted and decompressed. See `:as` above.
  * `:request` - see `:save-request?` above

  See [README](/README.md#usage) for example usages.
sourceraw docstring

unexceptional-status?clj

source

updateclj

(update m k f & args)
source

when-posclj

(when-pos v)
source

with-connection-poolcljmacro

(with-connection-pool _opts & body)

This macro is a no-op, but left in to support backward-compatibility with clj-http.

This macro is a no-op, but left in to support backward-compatibility
with clj-http.
sourceraw docstring

wrap-acceptclj

(wrap-accept client)
source

wrap-accept-encodingclj

(wrap-accept-encoding client)
source

wrap-basic-authclj

(wrap-basic-auth client)
source

wrap-content-typeclj

(wrap-content-type client)
source

wrap-decompressionclj

(wrap-decompression client)
source

wrap-exceptionsclj

(wrap-exceptions client)
source

wrap-form-paramsclj

(wrap-form-params client)
source

wrap-input-coercionclj

(wrap-input-coercion client)
source

wrap-methodclj

(wrap-method client)
source

wrap-nested-paramsclj

(wrap-nested-params client)
source

wrap-oauthclj

(wrap-oauth client)
source

wrap-output-coercionclj

(wrap-output-coercion client)
source

wrap-query-paramsclj

(wrap-query-params client)
source

wrap-redirectsclj

(wrap-redirects client)
source

wrap-requestclj

(wrap-request request)

Returns a batteries-included HTTP request function.

Returns a batteries-included HTTP request function.
sourceraw docstring

wrap-unknown-hostclj

(wrap-unknown-host client)
source

wrap-urlclj

(wrap-url client)
source

wrap-user-infoclj

(wrap-user-info client)
source

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

× close