{"id":13801372,"url":"https://github.com/dakrone/clj-http","last_synced_at":"2025-05-13T19:07:21.097Z","repository":{"id":1628497,"uuid":"2344720","full_name":"dakrone/clj-http","owner":"dakrone","description":"An idiomatic clojure http client wrapping the apache client. Officially supported version.","archived":false,"fork":false,"pushed_at":"2024-08-19T19:50:50.000Z","size":2077,"stargazers_count":1801,"open_issues_count":68,"forks_count":412,"subscribers_count":36,"default_branch":"3.x","last_synced_at":"2025-04-22T09:12:51.899Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://clojars.org/clj-http","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"openlayers/openlayers","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dakrone.png","metadata":{"files":{"readme":"README.org","changelog":"changelog.org","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-09-07T21:37:58.000Z","updated_at":"2025-04-16T20:04:16.000Z","dependencies_parsed_at":"2024-01-08T18:03:37.262Z","dependency_job_id":"bcc425aa-fed2-45cf-99ea-2f7fa54ee155","html_url":"https://github.com/dakrone/clj-http","commit_stats":{"total_commits":1087,"total_committers":187,"mean_commits":5.81283422459893,"dds":"0.42686292548298066","last_synced_commit":"f11a8dad027714c413ab7c34b3553eea3d1dcf12"},"previous_names":[],"tags_count":85,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakrone%2Fclj-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakrone%2Fclj-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakrone%2Fclj-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dakrone%2Fclj-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dakrone","download_url":"https://codeload.github.com/dakrone/clj-http/tar.gz/refs/heads/3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237777,"owners_count":21397399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:22.151Z","updated_at":"2025-04-27T04:23:28.548Z","avatar_url":"https://github.com/dakrone.png","language":"Clojure","funding_links":[],"categories":["HTTP","Clojure"],"sub_categories":[],"readme":"#+TITLE:    clj-http documentation\n#+AUTHOR:   Lee Hinman\n#+STARTUP:  align fold nodlcheck lognotestate showall\n#+OPTIONS:  H:4 num:nil toc:t \\n:nil @:t ::t |:t ^:{} -:t f:t *:t\n#+OPTIONS:  skip:nil d:(HIDE) tags:not-in-toc auto-id:t\n#+PROPERTY: header-args :results code :exports both :noweb yes\n#+HTML_HEAD: \u003cstyle type=\"text/css\"\u003e body {margin-right:15%; margin-left:15%;} \u003c/style\u003e\n#+LANGUAGE: en\n\n[[https://clojars.org/clj-http][file:https://img.shields.io/clojars/v/clj-http.svg]] [[https://github.com/dakrone/clj-http/actions?query=workflow%3A%22Clojure+CI%22][file:https://github.com/dakrone/clj-http/workflows/Clojure%20CI/badge.svg]] [[https://gitter.im/clj-http/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge][file:https://badges.gitter.im/clj-http/Lobby.svg]]\n\n* Table of Contents                                                     :TOC_3:\n:PROPERTIES:\n:CUSTOM_ID: h-aaf075ea-2f0e-4a45-871a-0f89c838fb4b\n:END:\n- [[#branches][Branches]]\n- [[#introduction][Introduction]]\n  - [[#overview][Overview]]\n  - [[#philosophy][Philosophy]]\n- [[#installation][Installation]]\n- [[#quickstart][Quickstart]]\n  - [[#head][HEAD]]\n  - [[#get][GET]]\n  - [[#put][PUT]]\n  - [[#post][POST]]\n  - [[#delete][DELETE]]\n  - [[#async-http-request][Async HTTP Request]]\n    - [[#cancelling-requests][Cancelling Requests]]\n  - [[#coercions][Coercions]]\n    - [[#input-coercion][Input coercion]]\n    - [[#output-coercion][Output coercion]]\n  - [[#headers][Headers]]\n  - [[#query-string-parameters][Query-string parameters]]\n  - [[#meta-tag-headers][Meta Tag Headers]]\n  - [[#link-headers][Link Headers]]\n  - [[#redirects][Redirects]]\n    - [[#how-to-create-a-custom-redirectstrategy][How to create a custom RedirectStrategy]]\n  - [[#cookies][Cookies]]\n    - [[#cookiestores][Cookiestores]]\n    - [[#keystores-trust-stores][Keystores, Trust-stores]]\n  - [[#exceptions][Exceptions]]\n  - [[#decompression][Decompression]]\n  - [[#debugging][Debugging]]\n    - [[#logging][Logging]]\n- [[#caching][Caching]]\n- [[#authentication][Authentication]]\n  - [[#basic-auth][Basic Auth]]\n  - [[#digest-auth][Digest Auth]]\n  - [[#ntlm-auth][NTLM Auth]]\n  - [[#oauth2][oAuth2]]\n- [[#advanced-usage][Advanced Usage]]\n  - [[#raw-request][Raw Request]]\n    - [[#boolean-options][Boolean options]]\n  - [[#persistent-connections][Persistent Connections]]\n  - [[#re-using-httpclient-between-requests][Re-using =HttpClient= between requests]]\n  - [[#proxies][Proxies]]\n  - [[#custom-middleware][Custom Middleware]]\n  - [[#modifying-apache-specific-features-of-the-httpclientbuilder-and-httpasyncclientbuilder][Modifying Apache-specific features of the =HttpClientBuilder= and =HttpAsyncClientBuilder=]]\n  - [[#incrementally-json-parsing][Incrementally JSON Parsing]]\n  - [[#dns-resolution][DNS Resolution]]\n- [[#development][Development]]\n  - [[#faking-responses][Faking Responses]]\n  - [[#optional-dependencies][Optional Dependencies]]\n  - [[#clj-http-lite][clj-http-lite]]\n  - [[#troubleshooting][Troubleshooting]]\n    - [[#verifyerror-class-orgcodehausjacksonsmilesmileparser-overrides-final-method-getbinaryvalue][VerifyError class org.codehaus.jackson.smile.SmileParser overrides final method getBinaryValue...]]\n    - [[#nohttpresponseexception--due-to-stale-connections][NoHttpResponseException ... due to stale connections**]]\n- [[#tests][Tests]]\n- [[#testimonials][Testimonials]]\n- [[#other-libraries-providing-middleware][Other Libraries Providing Middleware]]\n- [[#license][License]]\n\n* Branches\n:PROPERTIES:\n:CUSTOM_ID: h-e390585c-cbd8-4e94-b36b-4e9c27c16720\n:END:\n\nThere are branches for the major version numbers:\n\n- 2.x (no longer maintained except for security issues)\n- 3.x (current stable releases and the main Github branch)\n- master (which is 4.x, unreleased, based on version 5 of the Apache HTTP Client)\n\n* Introduction\n:PROPERTIES:\n:CUSTOM_ID: h-d893078a-b20b-4086-9272-3d9c28c86846\n:END:\n\n** Overview\n:PROPERTIES:\n:CUSTOM_ID: h-d8b17d06-124e-44fd-9c86-0399f39b0254\n:END:\n\nclj-http is an HTTP library wrapping the [[http://hc.apache.org/][Apache HttpComponents]] client. This\nlibrary has taken over from mmcgrana's clj-http.\n\n** Philosophy\n:PROPERTIES:\n:CUSTOM_ID: h-aa21d07d-333b-4ff2-93a9-ffdca31d8949\n:END:\n\nThe design of =clj-http= is inspired by the [[https://github.com/ring-clojure/ring][Ring]] protocol for Clojure HTTP\n server applications.\n\nThe client in =clj-http.core= makes HTTP requests according to a given Ring\nrequest map and returns [[https://github.com/ring-clojure/ring/blob/master/SPEC.md][Ring response maps]] corresponding to the resulting HTTP\nresponse. The function =clj-http.client/request= uses Ring-style middleware to\nlayer functionality over the core HTTP request/response implementation. Methods\nlike =clj-http.client/get= are sugar over this =clj-http.client/request=\nfunction.\n\n* Installation\n:PROPERTIES:\n:CUSTOM_ID: h-ddfce0e2-6797-4774-add5-d5cf5bfaaa17\n:END:\n\n=clj-http= is available as a Maven artifact from [[http://clojars.org/clj-http][Clojars]].\n\nWith Leiningen/Boot:\n\n#+BEGIN_SRC clojure\n[clj-http \"3.13.0\"]\n#+END_SRC\n\nIf you need an older version, a 2.x release is also available.\n\n#+BEGIN_SRC clojure\n[clj-http \"2.3.0\"]\n#+END_SRC\n\nclj-http 3.12.x supports clojure 1.6.0 and higher.\nclj-http 3.13.x supports clojure 1.8.0 and higher.\nclj-http 4.x will support clojure 1.7.0 and higher.\n\n* Quickstart\n:PROPERTIES:\n:CUSTOM_ID: h-65f0132e-1f96-4711-a84e-973817f37dd3\n:END:\n\nThe main HTTP client functionality is provided by the =clj-http.client= namespace.\n\nFirst, require it in the REPL:\n\n#+BEGIN_SRC clojure\n(require '[clj-http.client :as client])\n#+END_SRC\n\nOr in your application:\n\n#+BEGIN_SRC clojure\n(ns my-app.core\n  (:require [clj-http.client :as client]))\n#+END_SRC\n\nThe client supports simple =get=, =head=, =put=, =post=, =delete=, =copy=,\n=move=, =patch=, and =options= requests. Response are returned as [[https://github.com/ring-clojure/ring/blob/master/SPEC][Ring-style\nresponse maps]]:\n\n** HEAD\n:PROPERTIES:\n:CUSTOM_ID: h-79d1bb5f-c695-46a6-af4e-a64ca599c978\n:END:\n\n#+BEGIN_SRC clojure\n\n(client/head \"http://example.com/resource\")\n\n(client/head \"http://example.com/resource\" {:accept :json})\n\n#+END_SRC\n\n** GET\n:PROPERTIES:\n:CUSTOM_ID: h-89c164fb-85c2-4953-a8c4-a50867adf42a\n:END:\n\nExample requests:\n\n#+BEGIN_SRC clojure\n\n(client/get \"http://example.com/resources/id\")\n\n;; Setting options\n(client/get \"http://example.com/resources/3\" {:accept :json})\n(client/get \"http://example.com/resources/3\" {:accept :json :query-params {\"q\" \"foo, bar\"}})\n\n;; Specifying headers as either a string or collection:\n(client/get \"http://example.com\"\n            {:headers {\"foo\" [\"bar\" \"baz\"], \"eggplant\" \"quux\"}})\n\n;; Using either string or keyword header names:\n(client/get \"http://example.com\"\n            {:headers {:foo [\"bar\" \"baz\"], :eggplant \"quux\"}})\n\n;; Completely ignore cookies:\n(client/post \"http://example.com\" {:cookie-policy :none})\n;; There are also multiple ways to handle cookies\n(client/post \"http://example.com\" {:cookie-policy :default})\n(client/post \"http://example.com\" {:cookie-policy :netscape})\n(client/post \"http://example.com\" {:cookie-policy :standard})\n(client/post \"http://example.com\" {:cookie-policy :standard-strict})\n\n;; Cookies can be completely configurable with a custom spec by adding a\n;; function to return a cookie spec for parsing the cookie. For example, if you\n;; wanted to configure a spec provider to have a certain compatibility level:\n(client/post \"http://example.com\"\n             {:cookie-spec\n              (fn [http-context]\n                (println \"generating a new cookie spec\")\n                (.create\n                 (org.apache.http.impl.cookie.RFC6265CookieSpecProvider.\n                  org.apache.http.impl.cookie.RFC6265CookieSpecProvider$CompatibilityLevel/IE_MEDIUM_SECURITY\n                  (PublicSuffixMatcherLoader/getDefault))\n                 http-context))})\n;; Or a version with relaxed compatibility\n(client/post \"http://example.com\"\n             {:cookie-spec\n              (fn [http-context]\n                (println \"generating a new cookie spec\")\n                (.create\n                 (org.apache.http.impl.cookie.RFC6265CookieSpecProvider.\n                  org.apache.http.impl.cookie.RFC6265CookieSpecProvider$CompatibilityLevel/RELAXED\n                  (PublicSuffixMatcherLoader/getDefault))\n                 http-context))})\n\n;; Sometimes you want to do your own validation or something, which you can do\n;; by proxying the CookieSpecBase. Note that this doesn't actually return the\n;; cookies, because clj-http does its own cookie parsing. If you want to store\n;; the cookies from these methods you'll need to use a cookie store or put it in\n;; some datastructure yourself.\n(client/post \"http://example.com\"\n             {:cookie-spec\n              (fn [http-context]\n                (proxy [org.apache.http.impl.cookie.CookieSpecBase] []\n                  ;; Version and version header\n                  (getVersion [] 0)\n                  (getVersionHeader [] nil)\n                  ;; parse headers into cookie objects\n                  (parse [header cookie-origin] (java.util.ArrayList.))\n                  ;; Validate a cookie, throwing MalformedCookieException if the\n                  ;; cookies isn't valid\n                  (validate [cookie cookie-origin]\n                    (println \"validating:\" cookie))\n                  ;; Determine if a cookie matches the target location\n                  (match [cookie cookie-origin] true)\n                  ;; Format a list of cookies into a list of headers\n                  (formatCookies [cookies] (java.util.ArrayList.))))})\n\n;; If you have created your own registry for cookie policies, you can provide\n;; :cookie-policy-registry to use it. See\n;; clj-http.core/create-custom-cookie-policy-registry for an example of a custom\n;; registry\n(client/post \"http://example.com\"\n             {:cookie-policy-registry my-custom-policy-registry\n              :cookie-policy \"my-policy\"})\n\n;; Need to contact a server with an untrusted SSL cert?\n(client/get \"https://alioth.debian.org\" {:insecure? true})\n\n;; If you don't want to follow-redirects automatically:\n(client/get \"http://example.com/redirects-somewhere\" {:redirect-strategy :none})\n\n;; Only follow a certain number of redirects:\n(client/get \"http://example.com/redirects-somewhere\" {:max-redirects 5})\n\n;; Avoid throwing exceptions if redirected too many times:\n(client/get \"http://example.com/redirects-somewhere\" {:max-redirects 5 :redirect-strategy :graceful})\n\n;; Throw an exception if the get takes too long. Timeouts in milliseconds.\n(client/get \"http://example.com/redirects-somewhere\" {:socket-timeout 1000 :connection-timeout 1000})\n\n;; Query parameters\n(client/get \"http://example.com/search\" {:query-params {\"q\" \"foo, bar\"}})\n\n;; \"Nested\" query parameters\n;; (this yields a query string of `a[e][f]=6\u0026a[b][c]=5`)\n(client/get \"http://example.com/search\" {:query-params {:a {:b {:c 5} :e {:f 6}}}})\n\n;; Provide cookies — uses same schema as :cookies returned in responses\n;; (see the cookie store option for easy cross-request maintenance of cookies)\n(client/get \"http://example.com\"\n            {:cookies {\"ring-session\" {:discard true, :path \"/\", :value \"\", :version 0}}})\n\n;; Tell clj-http not to decode cookies from the response header\n(client/get \"http://example.com\" {:decode-cookies false})\n\n;; Support for IPv6!\n(client/get \"http://[2001:62f5:9006:e472:cabd:c8ff:fee3:8ddf]\")\n\n;; Super advanced, your own http-client-context and request-config\n(client/get \"http://example.com/get\"\n            {:http-client-context my-http-client-context\n             :http-request-config my-request-config})\n#+END_SRC\n\nThe client will also follow redirects on the appropriate =30*= status codes.\n\nThe client transparently accepts and decompresses the =gzip= and =deflate=\ncontent encodings.\n\n=:trace-redirects= will contain the chain of the redirections followed.\n\n** PUT\n:PROPERTIES:\n:CUSTOM_ID: h-1582cd6e-a6e8-49c8-96e3-28eee6128c31\n:END:\n\n#+BEGIN_SRC clojure\n\n(client/put \"http://example.com/api\" {:body \"my PUT body\"})\n\n#+END_SRC\n\n** POST\n:PROPERTIES:\n:CUSTOM_ID: h-32c8ca7a-0ef2-41b8-8158-20b0e2945e5d\n:END:\n\n#+BEGIN_SRC clojure\n\n;; Various options:\n(client/post \"http://example.com/api\"\n             {:basic-auth [\"user\" \"pass\"]\n              :body \"{\\\"json\\\": \\\"input\\\"}\"\n              :headers {\"X-Api-Version\" \"2\"}\n              :content-type :json\n              :socket-timeout 1000      ;; in milliseconds\n              :connection-timeout 1000  ;; in milliseconds\n              :accept :json})\n\n;; Send form params as a urlencoded body (POST or PUT)\n(client/post \"http://example.com\" {:form-params {:foo \"bar\"}})\n\n;; Send form params as a json encoded body (POST or PUT)\n(client/post \"http://example.com\" {:form-params {:foo \"bar\"} :content-type :json})\n\n;; Send form params as a json encoded body (POST or PUT) with options\n(client/post \"http://example.com\" {:form-params {:foo \"bar\"}\n                                   :content-type :json\n                                   :json-opts {:date-format \"yyyy-MM-dd\"}})\n\n;; You can also specify the encoding of form parameters\n(client/post \"http://example.com\" {:form-params {:foo \"bar\"}\n                                   :form-param-encoding \"ISO-8859-1\"})\n\n;; Send form params as a Transit encoded JSON body (POST or PUT) with options\n(client/post \"http://example.com\" {:form-params {:foo \"bar\"}\n                                   :content-type :transit+json\n                                   :transit-opts\n                                   {:encode {:handlers {}}\n                                    :decode {:handlers {}}}})\n\n;; Send form params as a Transit encoded MessagePack body (POST or PUT) with options\n(client/post \"http://example.com\" {:form-params {:foo \"bar\"}\n                                   :content-type :transit+msgpack\n                                   :transit-opts\n                                   {:encode {:handlers {}}\n                                    :decode {:handlers {}}}})\n\n;; Multipart form uploads/posts\n;; takes a vector of maps, to preserve the order of entities, :name\n;; will be used as the part name unless :part-name is specified\n(client/post \"http://example.org\" {:multipart [{:name \"title\" :content \"My Awesome Picture\"}\n                                               {:name \"Content/type\" :content \"image/jpeg\"}\n                                               {:name \"foo.txt\" :part-name \"eggplant\" :content \"Eggplants\"}\n                                               {:name \"file\" :content (clojure.java.io/file \"pic.jpg\")}]\n                                   ;; You can also optionally pass a :mime-subtype\n                                   :mime-subtype \"foo\"})\n\n;; Multipart :content values can be one of the following:\n;; String, InputStream, File, a byte-array, or an instance of org.apache.http.entity.mime.content.ContentBody\n;; Some Multipart bodies can also support more keys (like :encoding\n;; and :mime-type), check src/clj-http/multipart.clj to see all flags\n\n;; Apache's http client automatically retries on IOExceptions, if you\n;; would like to handle these retries yourself, you can specify a\n;; :retry-handler. Return true to retry, false to stop trying:\n(client/post \"http://example.org\" {:multipart [[\"title\" \"Foo\"]\n                                               [\"Content/type\" \"text/plain\"]\n                                               [\"file\" (clojure.java.io/file \"/tmp/missing-file\")]]\n                                   :retry-handler (fn [ex try-count http-context]\n                                                    (println \"Got:\" ex)\n                                                    (if (\u003e try-count 4) false true))})\n\n;; to handle a file with non-ascii filename, try :multipart-charset \"UTF-8\" and :multipart-mode BROWSER_COMPATIBLE\n;; see also: https://stackoverflow.com/questions/3393445/international-characters-in-filename-in-mutipart-formdata\n(import (org.apache.http.entity.mime HttpMultipartMode))\n\n(client/post \"http://example.org\" {:multipart [{:content (clojure.java.io/file \"日本語.txt\")}]\n                                   :multipart-mode HttpMultipartMode/BROWSER_COMPATIBLE\n                                   :multipart-charset \"UTF-8\"} )\n\n#+END_SRC\n\nA word about flattening nested =:query-params= and =:form-params= maps. There are essentially three\ndifferent ways to handle flattening them:\n\n- =:ignore-nested-query-string= :: Do not handle nested query parameters specially, treat them as\n     the exact text they come in as. Defaults to *false*.\n- =:flatten-nested-form-params= :: Flatten nested (map within a map) =:form-params= before encoding\n     it as the body. Defaults to *false*, meaning form params are encoded only\n     =x-www-form-urlencoded=.\n- =:flatten-nested-keys= :: An advanced way of specifying which keys having nested maps should be\n     flattened. A middleware function checks the previous two options\n     (=:ignore-nested-query-string= and =:flatten-nested-form-params=) and modifies this to be the\n     list that will be flattened.\n\n** DELETE\n:PROPERTIES:\n:CUSTOM_ID: h-c7165d6b-232a-439d-9390-8c05e6ef1e6f\n:END:\n\n#+BEGIN_SRC clojure\n\n(client/delete \"http://example.com/resource\")\n\n#+END_SRC\n\n** Async HTTP Request\n:PROPERTIES:\n:CUSTOM_ID: h-0e3eb987-5b2b-4874-97ef-b834394d083d\n:END:\nThe new async HTTP request API is a Ring-style async API.\nAll options for synchronous requests can be used in asynchronous requests.\nStarting an async request is easy, for example:\n\n#+BEGIN_SRC clojure\n;; :async? in options map need to be true\n(client/get \"http://example.com\"\n            {:async? true}\n            ;; respond callback\n            (fn [response] (println \"response is:\" response))\n            ;; raise callback\n            (fn [exception] (println \"exception message is: \" (.getMessage exception))))\n#+END_SRC\n\nAll exceptions thrown during the request will be passed to the raise callback.\n\n*** Cancelling Requests\n:PROPERTIES:\n:CUSTOM_ID: cancelling-requests\n:END:\n\nCalls to the http methods with =:async true= return an Apache [[https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/concurrent/BasicFuture.html][BasicFuture]] that you can call =.get=\nor =.cancel= on. See the Javadocs for =BasicFuture= [[https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/concurrent/BasicFuture.html][here]]. For instance:\n\n#+BEGIN_SRC clojure\n(import '(java.util.concurrent TimeoutException TimeUnit))\n\n(let [future (client/get \"http://example.com/slow-url\"\n                         {:async true :oncancel #(println \"request was cancelled\")}\n                         #(println :got %) #(println :err %))]\n  (try\n    (.get future 1 TimeUnit/SECONDS)\n    (catch TimeoutException e\n      ;; Cancel the request, it's taken too long\n      (.cancel future true))))\n#+END_SRC\n\n** Coercions\n:PROPERTIES:\n:CUSTOM_ID: h-8902cd95-e01e-4d9b-9dc8-5f5c8f04504b\n:END:\n\nclj-http allows coercing the body of the request either before it is sent (input coercion), or after\nit's received (output coercion) from the server.\n\n*** Input coercion\n:PROPERTIES:\n:CUSTOM_ID: h-bed01743-2209-473d-ae86-bd187f059e0c\n:END:\n\n#+BEGIN_SRC clojure\n;; body as a byte-array\n(client/post \"http://example.com/resources\" {:body my-byte-array})\n\n;; body as a string\n(client/post \"http://example.com/resources\" {:body \"string\"})\n\n;; :body-encoding is optional and defaults to \"UTF-8\"\n(client/post \"http://example.com/resources\"\n             {:body \"string\" :body-encoding \"UTF-8\"})\n\n;; body as a file\n(client/post \"http://example.com/resources\"\n             {:body (clojure.java.io/file \"/tmp/foo\") :body-encoding \"UTF-8\"})\n\n;; :length is optional for passing in an InputStream; if not\n;; supplied it will default to -1 to signal to HttpClient to use\n;; chunked encoding\n(client/post \"http://example.com/resources\"\n             {:body (clojure.java.io/input-stream \"/tmp/foo\")})\n\n(client/post \"http://example.com/resources\"\n             {:body (clojure.java.io/input-stream \"/tmp/foo\") :length 1000})\n#+END_SRC\n\n*** Output coercion\n:PROPERTIES:\n:CUSTOM_ID: h-0c8966a6-f220-4f1e-a79e-a520fb313f9e\n:END:\n\n#+BEGIN_SRC clojure\n;; The default output is a string body\n(client/get \"http://example.com/foo.txt\")\n\n;; Coerce as a byte-array\n(client/get \"http://example.com/favicon.ico\" {:as :byte-array})\n\n;; Coerce as something other than UTF-8 string\n(client/get \"http://example.com/string.txt\" {:as \"UTF-16\"})\n\n;; Coerce as json\n(client/get \"http://example.com/foo.json\" {:as :json})\n(client/get \"http://example.com/foo.json\" {:as :json-string-keys})\n\n;; Coerce as Transit encoded JSON or MessagePack\n(client/get \"http://example.com/foo\" {:as :transit+json})\n(client/get \"http://example.com/foo\" {:as :transit+msgpack})\n\n;; Coerce as a clojure datastructure\n(client/get \"http://example.com/foo.clj\" {:as :clojure})\n\n;; Coerce as x-www-form-urlencoded\n(client/post \"http://example.com/foo\" {:as :x-www-form-urlencoded})\n\n;; Try to automatically coerce the output based on the content-type\n;; header (this is currently a BETA feature!). Currently supports\n;; text, json and clojure (with automatic charset detection)\n;; clojure coercion requires \"application/clojure\" or\n;; \"application/edn\" in the content-type header\n(client/get \"http://example.com/foo.json\" {:as :auto})\n\n;; Return the body as a stream\n(client/get \"http://example.com/bigrequest.html\" {:as :stream})\n;; Note that the connection to the server will NOT be closed until the\n;; stream has been read\n\n;; Return the body as a java.io.BufferedReader\n(client/get \"http://example.com/bigrequest.html\" {:as :reader})\n;; As above, the connection will remain open until the stream has been\n;; read.  The reader will attempt to respect the server-specified charset,\n;; if any, defaulting to UTF-8.\n#+END_SRC\n\nOutput coercion with =:as :json=, =:as :json-string-keys= or =:as :x-www-form-urlencoded=, will only work with an optional dependency, see [[#optional-dependencies][Optional Dependencies]].\n\nBy default, JSON coercion is only applied when the response's status\nis considered \"unexceptional\". If the =:unexceptional-status= option\nis provided, then its value is a function which specifies what status\ncodes are unexceptional. =:unexceptional-status= defaults to\n=clj-http.client/unexceptional-status?=.\n\nIf you would like to change under what conditions coercion is applied,\nyou can send the =:coerce= option, which can be set to:\n\n#+BEGIN_SRC clojure\n:always        ;; always json decode the body\n:unexceptional ;; json decode when an HTTP response is considered unexceptional\n:exceptional   ;; json decode when an HTTP response is considered exceptional\n#+END_SRC\n\nThe =:coerce= setting defaults to =:unexceptional=.\n\n** Headers\n:PROPERTIES:\n:CUSTOM_ID: h-ef64574f-f9dc-4356-95b7-d55cc6737b44\n:END:\n\nclj-http's treatment of headers is a little more permissive than the [[https://github.com/ring-clojure/ring/blob/master/SPEC][ring spec]]\nspecifies.\n\nRather than forcing all request headers to be lowercase strings,\nclj-http allows strings or keywords of any case. Keywords will be\ntransformed into their canonical representation, so the :content-md5\nheader will be sent to the server as \"Content-MD5\", for instance.\nString keys in request headers, however, will be sent to the server\nwith their casing unchanged.\n\nResponse headers can be read as keywords or strings of any case. If\nthe server responds with a \"Date\" header, you could access the value\nof that header as :date, \"date\", \"Date\", etc.\n\nIf for some reason you require access to the original header name that\nthe server specified, it is available by invoking (keys ...) on the\nheader map.\n\nThis special treatment of headers is implemented in the\nwrap-header-map middleware, which (like any middleware) can be\ndisabled by using with-middleware to specify different behavior.\n\n** Query-string parameters\n:PROPERTIES:\n:CUSTOM_ID: h-dd49992c-a516-4af0-9735-4f4340773361\n:END:\n\nThere are four different ways that query string parameters for array values can\nbe generated, depending on what the resulting query string should look like,\nthey are:\n\n- A repeating parameter (default)\n- Array style\n- Indexed array style\n- Comma separated style\n\nHere is an example of the input and output for the ~:query-params~ parameter,\ncontrolled by the ~:multi-param-style~ option:\n\n#+BEGIN_SRC clojure\n;; default style, with :multi-param-style unset\n:a [1 2 3] =\u003e \"a=1\u0026a=2\u0026a=3\"\n;; with :multi-param-style :array, a repeating param with array suffix\n;; (PHP-style):\n:a [1 2 3] =\u003e \"a[]=1\u0026a[]=2\u0026a[]=3\"\n;; with :multi-param-style :indexed, a repeating param with array suffix and\n;; index (Rails-style):\n:a [1 2 3] =\u003e \"a[0]=1\u0026a[1]=2\u0026a[2]=3\"\n;; with :multi-param-style :comma-separated, a param with comma-separated values\n:a [1 2 3] =\u003e \"a=1,2,3\"\n#+END_SRC\n\n** Meta Tag Headers\n:PROPERTIES:\n:CUSTOM_ID: h-01663a63-8bc8-45da-8a3d-341402f3f3fa\n:END:\n\nHTML 4.01 allows using the tag ~\u003cmeta http-equiv=\"...\" /\u003e~ and HTML 5 allows\nusing the tag ~\u003cmeta charset=\"...\" /\u003e~ to specify a header that should be\ntreated as an HTTP response header. By default, clj-http will ignore the body of\nthe response (other than the regular output coercion), but if you need clj-http\nto parse the headers out of the body, you can use the =:decode-body-headers=\noption:\n\n#+BEGIN_SRC clojure\n;; without decoding body headers (defaults to off):\n(:headers (client/get \"http://www.yomiuri.co.jp/\"))\n=\u003e {\"server\" \"Apache\",\n    \"content-encoding\" \"gzip\",\n    \"content-type\" \"text/html\",\n    \"date\" \"Tue, 09 Oct 2012 18:02:41 GMT\",\n    \"cache-control\" \"max-age=0, no-cache\",\n    \"expires\" \"Tue, 09 Oct 2012 18:02:41 GMT\",\n    \"etag\" \"\\\"1dfb-2686-4cba2686fb8b1\\\"\",\n    \"pragma\" \"no-cache\",\n    \"connection\" \"close\"}\n\n;; with decoding body headers, notice the content-type,\n;; content-style-type and content-script-type headers:\n(:headers (client/get \"http://www.yomiuri.co.jp/\" {:decode-body-headers true}))\n=\u003e {\"server\" \"Apache\",\n    \"content-encoding\" \"gzip\",\n    \"content-script-type\" \"text/javascript\",\n    \"content-style-type\" \"text/css\",\n    \"content-type\" \"text/html; charset=Shift_JIS\",\n    \"date\" \"Tue, 09 Oct 2012 18:02:59 GMT\",\n    \"cache-control\" \"max-age=0, no-cache\",\n    \"expires\" \"Tue, 09 Oct 2012 18:02:59 GMT\",\n    \"etag\" \"\\\"1dfb-2686-4cba2686fb8b1\\\"\",\n    \"pragma\" \"no-cache\",\n    \"connection\" \"close\"}\n#+END_SRC\n\nThis can be used to have clj-http correctly interpret the body's charset by\nusing:\n\n#+BEGIN_SRC clojure\n(client/get \"http://www.yomiuri.co.jp/\" {:decode-body-headers true :as :auto})\n=\u003e ;; correctly formatted :body (Shift_JIS charset instead of UTF-8)\n#+END_SRC\n\nNote that this feature is currently beta and uses [[https://github.com/weavejester/crouton][Crouton]] to parse the body of\nthe request. If you want to use this feature, you can include Crouton in\naddition to clj-http as a dependency like so:\n\n#+BEGIN_SRC clojure\n(defproject foo \"0.1.0-SNAPSHOT\"\n  :dependencies [[org.clojure/clojure \"1.3.0\"]\n                 [clj-http \"0.6.0\"]\n                 [crouton \"1.0.0\"]])\n#+END_SRC\n\nNote also that HEAD requests will not return a body, in which case this setting will have no effect.\n\nclj-http will automatically disable the =:decode-body-headers= option.\n\n** Link Headers\n:PROPERTIES:\n:CUSTOM_ID: h-f7464c54-4928-474f-9132-08e6b6f3c19d\n:END:\n\nclj-http parses any [[http://tools.ietf.org/html/rfc5988][link headers]] returned in the response, and adds them to the\n=:links= key on the response map. This is particularly useful for paging RESTful\nAPIs:\n\n#+BEGIN_SRC clojure\n(:links (client/get \"https://api.github.com/gists\"))\n=\u003e {:next {:href \"https://api.github.com/gists?page=2\"}\n    :last {:href \"https://api.github.com/gists?page=22884\"}}\n#+END_SRC\n\n** Redirects\n:PROPERTIES:\n:CUSTOM_ID: h-71c966ae-f764-4bd7-801c-0f3c8413c502\n:END:\n\nclj-http conforms its behaviour regarding automatic redirects to the [[https://tools.ietf.org/html/rfc2616#section-10.3][RFC]].\n\nIt means that redirects on status =301=, =302=, =307= and =308= are not redirected on\nmethods other than =GET= and =HEAD=. If you want a behaviour closer to what most\nbrowser have, you can set =:redirect-strategy= to =:lax= in your request to have\nautomatic redirection work on all methods by transforming the method of the\nrequest to =GET=.\n\nRedirect Options:\n\n- =:trace-redirects= :: If true, clj-http will enhance the response object with a\n     list of redirected URLs with key: =:trace-redirects=.\n- =:redirect-strategy= :: Sets the redirect strategy for clj-http. Accepts the following:\n  - =:none=     - Perform no redirects\n  - =:default=  - See https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/impl/client/DefaultRedirectStrategy.html\n  - =:lax=      - See https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/impl/client/LaxRedirectStrategy.html\n  - =:graceful= - Similar to =:default=, but does not throw exceptions when max redirects is reached. This is the redirects behaviour in 2.x\n  - =nil=       - When nil, assumes =:default=\n\nYou may also pass in an instance of RedirectStrategy (in the =:redirect-strategy= key) if you want a\nbehavior that's not implemented.\n\nAdditionally, clj-http will attempt to validate that a redirect host is not invalid, you can disable\nthis by setting =:validate-redirects false= in the request (the default is true)\n\nNOTE: The options =:force-redirects= and =:follow-redirects= (present in clj-http 2.x are no longer\nused). You can use =:graceful= to mostly emulate the old redirect behaviour.\n\n*** How to create a custom RedirectStrategy\n:PROPERTIES:\n:CUSTOM_ID: h:a3b8b124-411f-4c4c-ac4b-777624e76bf1\n:END:\nAs mentioned earlier, it's possible to pass a custom instance of RedirectStrategy. The snippet below shows how to create a custom =RedirectStrategy= by wrapping the default strategy.\n\n#+begin_src clojure\n  (def default-strategy org.apache.http.impl.client.DefaultRedirectStrategy/INSTANCE)\n\n  (def logging-redirect-strategy\n    (reify org.apache.http.client.RedirectStrategy\n      (getRedirect [this request response context]\n        (println \"attempting redirect...\")\n        (.getRedirect default-strategy request response context))\n      (isRedirected [this request response context]\n        (println \"checking isRedirected\")\n        (.isRedirected default-strategy request response context))))\n\n  (client/get \"https://httpbin.org/absolute-redirect/3\" {:redirect-strategy logging-redirect-strategy})\n  ;; this will output the following:\n  ;;\n  ;;   checking isRedirected\n  ;;   attempting redirect...\n  ;;   checking isRedirected\n  ;;   attempting redirect...\n  ;;   checking isRedirected\n  ;;   attempting redirect...\n  ;;   checking isRedirected\n#+end_src\n\n\n** Cookies\n:PROPERTIES:\n:CUSTOM_ID: h-3bb89b16-4be3-455e-98ec-c5ca5830ddb9\n:END:\n\n*** Cookiestores\n:PROPERTIES:\n:CUSTOM_ID: h-1d86fe30-f690-4c2a-9a1c-231669f4591a\n:END:\n\nclj-http can simplify the maintenance of cookies across requests if it is\nprovided with a _cookie store_.\n\n#+BEGIN_SRC clojure\n(binding [clj-http.core/*cookie-store* (clj-http.cookies/cookie-store)]\n  (client/post \"http://example.com/login\" {:form-params {:username \"...\"\n                                                         :password \"...\"}})\n  (client/get \"http://example.com/secured-page\")\n  ...)\n#+END_SRC\n\n(The =clj-http.cookies/cookie-store= function returns a new empty instance of a\ndefault implementation of =org.apache.http.client.CookieStore=.)\n\nThis will allow cookies to only be _written_ to the cookie store. Cookies from\nthe cookie-store will not automatically be sent with future requests.\n\nIf you would like cookies from the cookie-store to automatically be sent with\neach request, specify the cookie-store with the =:cookie-store= option:\n\n#+BEGIN_SRC clojure\n(let [my-cs (clj-http.cookies/cookie-store)]\n  (client/post \"http://example.com/login\" {:form-params {:username \"...\"\n                                                         :password \"...\"}\n                                           :cookie-store my-cs})\n  (client/post \"http://example.com/update\" {:body my-data\n                                            :cookie-store my-cs}))\n#+END_SRC\n\nYou can also use the =get-cookies= function to retrieve the cookies\nfrom a cookie store:\n\n#+BEGIN_SRC clojure\n(def cs (clj-http.cookies/cookie-store))\n\n(client/get \"http://google.com\" {:cookie-store cs})\n\n(clojure.pprint/pprint (clj-http.cookies/get-cookies cs))\n{\"NID\"\n {:domain \".google.com\",\n  :expires #\u003cDate Tue Oct 02 10:12:06 MDT 2012\u003e,\n  :path \"/\",\n  :value\n  \"58=c387....\",\n  :version 0},\n \"PREF\"\n {:domain \".google.com\",\n  :expires #\u003cDate Wed Apr 02 10:12:06 MDT 2014\u003e,\n  :path \"/\",\n  :value\n  \"ID=3ba...:FF=0:TM=133...:LM=133...:S=_iRM...\",\n  :version 0}}\n#+END_SRC\n\n*** Keystores, Trust-stores\n:PROPERTIES:\n:CUSTOM_ID: h-7968467a-1441-4a73-9307-9a7a5fd8e733\n:END:\n\nYou can also specify your own keystore/trust-store to be used:\n\n#+BEGIN_SRC clojure\n(client/get \"https://example.com\" {:keystore \"/path/to/keystore.ks\"\n                                   :keystore-type \"jks\" ; default: jks\n                                   :keystore-pass \"secretpass\"\n                                   :trust-store \"/path/to/trust-store.ks\"\n                                   :trust-store-type \"jks\" ; default jks\n                                   :trust-store-pass \"trustpass\"})\n#+END_SRC\n\nThe =:keystore/:trust-store= values may be either paths to keystore\nfiles or =KeyStore= instances.\n\n** Exceptions\n:PROPERTIES:\n:CUSTOM_ID: h-ed9e04f1-1c7b-4c2e-9259-94d2a3e65a89\n:END:\n\nThe client will throw exceptions on, well, exceptional status codes, meaning all\nHTTP responses other than =#{200 201 202 203 204 205 206 207 300 301 302 303 304\n307}=. clj-http will throw a [[http://github.com/scgilardi/slingshot][Slingshot]] Stone that can be caught by a regular\n=(catch Exception e ...)= or in Slingshot's =try+= block:\n\n#+BEGIN_SRC clojure\n(client/get \"http://example.com/broken\")\n=\u003e ExceptionInfo clj-http: status 404  clj-http.client/wrap-exceptions/fn--583 (client.clj:41)\n;; Or, if you would like the Exception message to contain the entire response:\n(client/get \"http://example.com/broken\" {:throw-entire-message? true})\n=\u003e ExceptionInfo clj-http: status 404 {:status 404,\n                                       :headers {\"server\" \"nginx/1.0.4\",\n                                                 \"x-runtime\" \"12ms\",\n                                                 \"content-encoding\" \"gzip\",\n                                                 \"content-type\" \"text/html; charset=utf-8\",\n                                                 \"date\" \"Mon, 17 Oct 2011 23:15 :36 GMT\",\n                                                 \"cache-control\" \"no-cache\",\n                                                 \"status\" \"404 Not Found\",\n                                                 \"transfer-encoding\" \"chunked\",\n                                                 \"connection\" \"close\"},\n                                       :body \"...body here...\"}\n   clj-http.client/wrap-exceptions/fn--584 (client.clj:42\n\n;; You can also ignore HTTP-status-code exceptions and handle them yourself:\n(client/get \"http://example.com/broken\" {:throw-exceptions false})\n;; Or ignore an unknown host (methods return 'nil' if this is set to\n;; true and the host does not exist:\n(client/get \"http://example.invalid\" {:ignore-unknown-host? true})\n;; Or customize the http statuses that will not throw:\n(client/get \"http://example.com/broken\" {:unexceptional-status #(\u003c= 200 % 299)})\n#+END_SRC\n\n(spacing added by me to be human readable)\n\nHow to use with Slingshot:\n\n#+BEGIN_SRC clojure\n; Response map is thrown as exception obj.\n; We filter out by status codes\n(try+\n  (client/get \"http://example.com/broken\")\n  (catch [:status 403] {:keys [request-time headers body]}\n    (log/warn \"403\" request-time headers))\n  (catch [:status 404] {:keys [request-time headers body]}\n    (log/warn \"NOT Found 404\" request-time headers body))\n  (catch Object _\n    (log/error (:throwable \u0026throw-context) \"unexpected error\")\n    (throw+)))\n#+END_SRC\n\n** Decompression\n:PROPERTIES:\n:CUSTOM_ID: h-f780c96c-90be-4d83-9b53-227a9e5942ab\n:END:\n\nBy default, clj-http will add the ={\"Accept-Encoding\" \"gzip, deflate\"}= header\nto requests, and automatically decompress the resulting gzip or deflate stream\nif the =Content-Encoding= header is found on the response. If this is undesired,\nthe ={:decompress-body false}= option can be specified:\n\n#+BEGIN_SRC clojure\n;; Auto-decompression used: (google requires a user-agent to send gzip data)\n(def h {\"User-Agent\" \"Mozilla/5.0 (Windows NT 6.1;) Gecko/20100101 Firefox/13.0.1\"})\n(def resp (client/get \"http://google.com\" {:headers h}))\n(:orig-content-encoding resp)\n=\u003e \"gzip\" ;; \u003c= google sent response gzipped\n\n;; and without decompression:\n(def resp2 (client/get \"http://google.com\" {:headers h :decompress-body false})\n(:orig-content-encoding resp2)\n=\u003e nil\n#+END_SRC\n\nIf clj-http decompresses something, the \"content-encoding\" header is removed\nfrom the headers (because the encoding is no longer true). This allows clj-http\nto be used as a pass-through proxy with ring. The original content-encoding is\navailable as =:orig-content-encoding= in the response map if auto-decompression\nis enabled.\n\n** Debugging\n:PROPERTIES:\n:CUSTOM_ID: debugging\n:END:\n\nThere are four debugging methods you can use:\n\n#+BEGIN_SRC clojure\n;; print request info to *out*:\n(client/get \"http://example.org\" {:debug true})\n\n;; print request info to *out*, including request body:\n(client/post \"http://example.org\" {:debug true :debug-body true :body \"...\"})\n\n;; save the request that was sent in a :request key in the response:\n(client/get \"http://example.org\" {:save-request? true})\n\n;; save the request that was sent in a :request key in the response,\n;; including the body content:\n(client/get \"http://example.org\" {:save-request? true :debug-body true})\n\n;; add an HttpResponseInterceptor to the request. This callback\n;; is called for each redirects with the following args:\n;; ^HttpResponse resp, HttpContext^ ctx\n;; this allows low level debugging + access to socket.\n;; see http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/HttpResponseInterceptor.html\n(client/get \"http://example.org\" {:response-interceptor (fn [resp ctx] (println ctx))})\n#+END_SRC\n\n*** Logging\n:PROPERTIES:\n:CUSTOM_ID: h-0d505652-d453-48a2-a868-46aef2b8af66\n:END:\n\nFinally, if you want to access the logging that the Apache client does internally, you can set up\nyour dependencies to add the [[https://logging.apache.org/log4j/2.x/][log4j2]] libraries and configure the logging for clj-http. In order to do\nthis, you'll need to add\n\n#+BEGIN_SRC clojure\n[org.apache.logging.log4j/log4j-api \"2.11.0\"]\n[org.apache.logging.log4j/log4j-core \"2.11.0\"]\n[org.apache.logging.log4j/log4j-1.2-api \"2.11.0\"]\n#+END_SRC\n\nTo your =project.clj= and have a usable log4j2.properties. I have provided one in\n=resources/log4j2.properties=. Make sure to set:\n\n#+BEGIN_SRC fundamental\nrootLogger.level = debug\n#+END_SRC\n\nIf you want to see debug information (or \"trace\" for trace logging). When you perform a request you\nshould see something akin to this in the logs:\n\n#+BEGIN_SRC fundamental\n[2018-03-20T20:36:34,635][DEBUG][o.a.h.c.p.RequestAddCookies] CookieSpec selected: default\n[2018-03-20T20:36:34,635][DEBUG][o.a.h.c.p.RequestAuthCache] Auth cache not set in the context\n[2018-03-20T20:36:34,635][DEBUG][o.a.h.i.c.BasicHttpClientConnectionManager] Get connection for route {s}-\u003ehttps://example.com:443\n[2018-03-20T20:36:34,636][DEBUG][o.a.h.i.c.DefaultManagedHttpClientConnection] http-outgoing-1: set socket timeout to 0\n[2018-03-20T20:36:34,636][DEBUG][o.a.h.i.e.MainClientExec ] Opening connection {s}-\u003ehttps://example.com:443\n[2018-03-20T20:36:34,644][DEBUG][o.a.h.i.c.DefaultHttpClientConnectionOperator] Connecting to example.com/10.0.0.1:443\n[2018-03-20T20:36:34,644][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory] Connecting socket to example.com/10.0.0.1:443 with timeout 0\n[2018-03-20T20:36:34,692][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory] Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]\n[2018-03-20T20:36:34,693][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory] Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, ... etc ...]\n[2018-03-20T20:36:34,693][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory] Starting handshake\n[2018-03-20T20:36:34,841][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory] Secure session established\n[2018-03-20T20:36:34,842][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory]  negotiated protocol: TLSv1.2\n[2018-03-20T20:36:34,842][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory]  negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\n[2018-03-20T20:36:34,843][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory]  peer principal: CN=example.com\n[2018-03-20T20:36:34,843][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory]  peer alternative names: [example.com, www.example.com]\n[2018-03-20T20:36:34,843][DEBUG][o.a.h.c.s.SSLConnectionSocketFactory]  issuer principal: CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US\n[2018-03-20T20:36:34,844][DEBUG][o.a.h.i.c.DefaultHttpClientConnectionOperator] Connection established 192.168.0.29:36792\u003c-\u003e10.0.0.1:443\n[2018-03-20T20:36:34,844][DEBUG][o.a.h.i.e.MainClientExec ] Executing request POST /post HTTP/1.1\n[2018-03-20T20:36:34,844][DEBUG][o.a.h.i.e.MainClientExec ] Target auth state: UNCHALLENGED\n[2018-03-20T20:36:34,844][DEBUG][o.a.h.i.e.MainClientExec ] Proxy auth state: UNCHALLENGED\n[2018-03-20T20:36:34,845][DEBUG][o.a.h.headers            ] http-outgoing-1 \u003e\u003e POST /post HTTP/1.1\n[2018-03-20T20:36:34,845][DEBUG][o.a.h.headers            ] http-outgoing-1 \u003e\u003e Connection: close\n[2018-03-20T20:36:34,845][DEBUG][o.a.h.headers            ] http-outgoing-1 \u003e\u003e accept-encoding: gzip, deflate\n[2018-03-20T20:36:34,845][DEBUG][o.a.h.headers            ] http-outgoing-1 \u003e\u003e Content-Length: 14\n[2018-03-20T20:36:34,845][DEBUG][o.a.h.headers            ] http-outgoing-1 \u003e\u003e Content-Type: text/plain; charset=UTF-8\n[2018-03-20T20:36:34,846][DEBUG][o.a.h.headers            ] http-outgoing-1 \u003e\u003e Host: example.com\n[2018-03-20T20:36:34,846][DEBUG][o.a.h.headers            ] http-outgoing-1 \u003e\u003e User-Agent: Apache-HttpClient/4.5.5 (Java/9.0.1)\n[2018-03-20T20:36:34,846][DEBUG][o.a.h.wire               ] http-outgoing-1 \u003e\u003e \"POST /post HTTP/1.1[\\r][\\n]\"\n[2018-03-20T20:36:34,846][DEBUG][o.a.h.wire               ] http-outgoing-1 \u003e\u003e \"Connection: close[\\r][\\n]\"\n[2018-03-20T20:36:34,846][DEBUG][o.a.h.wire               ] http-outgoing-1 \u003e\u003e \"accept-encoding: gzip, deflate[\\r][\\n]\"\n[2018-03-20T20:36:34,847][DEBUG][o.a.h.wire               ] http-outgoing-1 \u003e\u003e \"Content-Length: 14[\\r][\\n]\"\n[2018-03-20T20:36:34,847][DEBUG][o.a.h.wire               ] http-outgoing-1 \u003e\u003e \"Content-Type: text/plain; charset=UTF-8[\\r][\\n]\"\n[2018-03-20T20:36:34,847][DEBUG][o.a.h.wire               ] http-outgoing-1 \u003e\u003e \"Host: example.com[\\r][\\n]\"\netc etc it will go on forever and be very verbose\n#+END_SRC\n\nThis provides both the data sent and received on the wire for debugging purposes.\n\nI've also provided an example for changing the log level from clojure in\n=examples/logging-apache-requests.clj=.\n\n* Caching\n:PROPERTIES:\n:CUSTOM_ID: h-2c4ee611-ca22-432e-9c33-18040566661e\n:END:\n\nclj-http supports Apache's caching client, essentially it \"provides an HTTP/1.1-compliant caching\nlayer to be used with HttpClient--the Java equivalent of a browser cache.\" (see [[https://hc.apache.org/httpcomponents-client-ga/tutorial/html/caching.html][the explanation in\nthe apache docs]]). In order to use the cache, a reusable connection manager *and* http-client must be\nused.\n\nAn example of basic usage with the default options:\n\n#+BEGIN_SRC clojure\n(let [cm (conn/make-reusable-conn-manager {})\n      client (:http-client (http/get \"http://example.com\"\n                                     {:connection-manager cm :cache true}))]\n  (http/get \"http://example.com\"\n            {:connection-manager cm :http-client client :cache true})\n  (http/get \"http://example.com\"\n            {:connection-manager cm :http-client client :cache true})\n  (http/get \"http://example.com\"\n            {:connection-manager cm :http-client client :cache true}))\n#+END_SRC\n\nYou can build your own cache config by providing either a map of caching configuration options, or\nby providing a =CacheConfig= object, as seen below:\n\n#+BEGIN_SRC clojure\n(let [cm (conn/make-reusable-conn-manager {})\n      cache-config (core/build-cache-config\n                    {:cache-config {:max-object-size 4096}})\n      client (:http-client (http/get \"http://example.com\"\n                                     {:connection-manager cm :cache true}))]\n  (http/get \"http://example.com\"\n            ;; Use the default cache config settings\n            {:connection-manager cm :http-client client :cache true})\n  (http/get \"http://example.com\"\n            {:connection-manager cm :http-client client :cache true\n             ;; Provide cache configuration options as a map\n             :cache-config {:max-object-size 9152\n                            :max-cache-entries 100}})\n  (http/get \"http://example.com\"\n            {:connection-manager cm :http-client client :cache true\n             ;; Provide the cache configuration as a CacheConfig object\n             :cache-config cache-config}))\n#+END_SRC\n\nIn the response, clj-http provides the =:cached= key to indicate whether the response was cached,\nmissed, etc:\n\n- nil :: Caching was not used for this request\n- =:CACHE_HIT= :: A response was generated from the cache with no requests sent upstream.\n- =:CACHE_MISS= :: The response came from an upstream server.\n- =:CACHE_MODULE_RESPONSE= :: The response was generated directly by the caching module.\n- =:VALIDATED= :: The response was generated from the cache after validating the entry with the origin server.\n\n* Authentication\n:PROPERTIES:\n:CUSTOM_ID: h-87f38469-36b4-44c6-ae74-0d8f5e80c2ed\n:END:\n\n** Basic Auth\n:PROPERTIES:\n:CUSTOM_ID: h-d3ea348f-88ed-4193-bb16-d8d5accdc2aa\n:END:\n\n#+BEGIN_SRC clojure\n\n(client/get \"http://example.com/protected\" {:basic-auth [\"user\" \"pass\"]})\n(client/get \"http://example.com/protected\" {:basic-auth \"user:pass\"})\n\n#+END_SRC\n\n** Digest Auth\n:PROPERTIES:\n:CUSTOM_ID: h-d1904589-e71e-43db-8b93-0f94ccecaabe\n:END:\n\n#+BEGIN_SRC clojure\n\n(client/get \"http://example.com/protected\" {:digest-auth [\"user\" \"pass\"]})\n\n#+END_SRC\n\n** NTLM Auth\n:PROPERTIES:\n:CUSTOM_ID: h-AE80FFDC-2016-4883-9512-2BE16640339D\n:END:\n\n#+BEGIN_SRC clojure\n\n(client/get \"http://example.com/protected\" {:ntlm-auth [\"user\" \"pass\" \"host\" \"domain\"]})\n\n#+END_SRC\n\n** oAuth2\n:PROPERTIES:\n:CUSTOM_ID: h-dd077440-a1de-437e-b34e-5d6d0d1da4bd\n:END:\n\n#+BEGIN_SRC clojure\n\n(client/get \"http://example.com/protected\" {:oauth-token \"secret-token\"})\n\n#+END_SRC\n\n* Advanced Usage\n:PROPERTIES:\n:CUSTOM_ID: h-d52ca837-a575-402f-81fe-53241d85f2db\n:END:\n\n** Raw Request\n:PROPERTIES:\n:CUSTOM_ID: h-0d2eadbf-c1ad-4514-a932-9d173582a790\n:END:\n\nA more general =request= function is also available, which is useful as a\nprimitive for building higher-level interfaces:\n\n#+BEGIN_SRC clojure\n(defn api-action [method path \u0026 [opts]]\n  (client/request\n    (merge {:method method :url (str \"http://example.com/\" path)} opts)))\n#+END_SRC\n\n*** Boolean options\n:PROPERTIES:\n:CUSTOM_ID: h-a37c718c-43bb-43ce-936a-21ef65147295\n:END:\n\nSince 0.9.0, all boolean options can be expressed as either ={:debug true}= or\n={:debug? true}=, with or without the question mark.\n\n** Persistent Connections\n:PROPERTIES:\n:CUSTOM_ID: h-4e9f116d-c293-4a0c-8e11-435c440bfe97\n:END:\n\nclj-http can use persistent connections to speed up connections if multiple\nconnections are being used:\n\n#+BEGIN_SRC clojure\n(with-connection-pool {:timeout 5 :threads 4 :insecure? false :default-per-route 10}\n  (get \"http://example.org/1\")\n  (post \"http://example.org/2\")\n  (get \"http://example.org/3\")\n  ...\n  (get \"http://example.org/999\"))\n#+END_SRC\n\nFor async request, you can use =with-async-connection-pool=\n\n#+BEGIN_SRC clojure\n(with-async-connection-pool {:timeout 5 :threads 4 :insecure? false :default-per-route 10}\n  (get \"http://example.org/1\" {:async? true} resp1 exce1)\n  (post \"http://example.org/2\" {:async? true} resp2 exce2)\n  (get \"http://example.org/3\" {:async? true} resp3 exce3)\n  ...\n  (get \"http://example.org/999\" {:async? true} resp999 exce999))\n#+END_SRC\n\nThis is MUCH faster than sequentially performing all requests, because a\npersistent connection can be used instead creating a new connection for each\nrequest.\n\nIf you want to start an async request in the =respond= callback of an async request and\nreuse the pool context, just use =reuse-pool=.\n\n#+BEGIN_SRC clojure\n(with-async-connection-pool {:timeout 5 :threads 4 :insecure? false :default-per-route 10}\n  (get \"http://example.org/1\" {:async? true} resp1 exce1)\n  (post \"http://example.org/2\"\n        {:async? true}\n        (fn [resp] (get \"http://example.org/3\"\n                        (reuse-pool {:async? true} resp)\n                        resp3 exce3))\n        exce2))\n#+END_SRC\n\nThere are many advanced options available when creating asynchronous connection pools that can be\nconfigured by passing an =:io-config= map in the connection manager parameters. It supports:\n\n- =:connect-timeout=\n- =:interest-op-queued=\n- =:io-thread-count=\n- =:rcv-buf-size=\n- =:select-interval=\n- =:shutdown-grace-period=\n- =:snd-buf-size=\n- =:so-keep-alive=\n- =:so-linger=\n- =:so-timeout=\n- =:tcp-no-delay=\n\nSee the docstring on =with-async-connection-pool= for more information about these options.\n\nIf you would prefer to handle managing the connection manager yourself, you can\ncreate a connection manager and specify it for each request:\n\n#+BEGIN_SRC clojure\n(def cm (clj-http.conn-mgr/make-reusable-conn-manager {:timeout 2 :threads 3}))\n(def cm2 (clj-http.conn-mgr/make-reusable-conn-manager {:timeout 10 :threads 1}))\n\n(get \"http://example.org/1\" {:connection-manager cm2})\n(post \"http://example.org/2\" {:connection-manager cm})\n(get \"http://example.org/3\" {:connection-manager cm2})\n\n;; Don't forget to shut it down when you're done!\n(clj-http.conn-mgr/shutdown-manager cm)\n(clj-http.conn-mgr/shutdown-manager cm2)\n#+END_SRC\n\nSee the docstring on =make-reusable-conn-manager= for options and default\nvalues.\n\nIn the current version, pooled async request CANNOT specify connection manager.\n\n** Re-using =HttpClient= between requests\n:PROPERTIES:\n:CUSTOM_ID: h-b79b07fb-d024-49a2-a7f7-53863d1b8d6d\n:END:\n\nIn some cases, you may want to re-use the same =HttpClient= object between requests, either so you\ndon't have to build it every time, or because you make some configuration change to the request.\nclj-http will return the built HTTP client in =:http-client= which you can then specify in\nsubsequent requests (with =:http-client=). Note that in order to reuse the client a connection\nmanager must be used.\n\n#+BEGIN_SRC clojure\n;; Re-use the HttpClient clj-http builds for you:\n(let [cm (conn/make-reusable-conn-manager {})\n      resp (client/get \"http://example.com\" {:connection-manager cm})\n      hclient (:http-client resp)]\n  (client/get \"http://example.com/1\"\n              {:connection-manager cm :http-client hclient})\n  (client/get \"http://example.com/2\"\n              {:connection-manager cm :http-client hclient})\n  (client/get \"http://example.com/3\"\n              {:connection-manager cm :http-client hclient}))\n\n;; You can also build your own, using clj-http's helper or manually building it:\n(let [cm (conn/make-reusable-conn-manager {})\n      hclient (core/build-http-client {} false cm)]\n  (client/get \"http://example.com/1\"\n              {:connection-manager cm :http-client hclient})\n  (client/get \"http://example.com/2\"\n              {:connection-manager cm :http-client hclient})\n  (client/get \"http://example.com/3\"\n              {:connection-manager cm :http-client hclient}))\n\n;; Async http clients may also be created and re-used:\n(let [acm (conn/make-reuseable-async-conn-manager {})\n      ahclient (core/build-async-http-client {} acm)]\n  (client/get \"http://example.com/1\"\n              {:connection-manager cm :http-client ahclient}\n              handle-response handle-failure)\n  (client/get \"http://example.com/2\"\n              {:connection-manager cm :http-client ahclient}\n              handle-response handle-failure)\n  (client/get \"http://example.com/3\"\n              {:connection-manager cm :http-client ahclient}\n              handle-response handle-failure))\n#+END_SRC\n\n** Proxies\n:PROPERTIES:\n:CUSTOM_ID: h-49f9ca81-0bad-4cd8-87ac-c09a85fa5500\n:END:\n\nA proxy can be specified by setting the Java properties: =\u003cscheme\u003e.proxyHost=\nand =\u003cscheme\u003e.proxyPort= where =\u003cscheme\u003e= is the client scheme used (normally\n'http' or 'https'). =http.nonProxyHosts= allows you to specify a pattern for\nhostnames which do not require proxy routing - this is shared for all schemes.\nAdditionally, per-request proxies can be specified with the =proxy-host= and\n=proxy-port= options (this overrides =http.nonProxyHosts= too):\n\n#+BEGIN_SRC clojure\n(client/get \"http://example.com\" {:proxy-host \"127.0.0.1\" :proxy-port 8118})\n#+END_SRC\n\nProxy credentials can also be explicitly set as\n\n#+BEGIN_SRC clojure\n(client/get \"http://example.com\" {:proxy-host \"127.0.0.1\" :proxy-port 8118 :proxy-user \"proxy-user\" :proxy-pass \"superSecurePassword\"})\n#+END_SRC\n\nYou can also specify the =proxy-ignore-hosts= parameter with a list of\nhosts where the proxy should be ignored. By default this list is\n=#{\"localhost\" \"127.0.0.1\"}=.\n\nA SOCKS proxy can be used by creating a proxied connection manager with\n=clj-http.conn-mgr/make-socks-proxied-conn-manager=. Then using that connection\nmanager in the request.\n\nFor example if you wanted to connect to a local socks proxy on port =8081= you\nwould:\n\n#+BEGIN_SRC clojure\n(ns foo.bar\n  (:require [clj-http.client :as client]\n            [clj-http.conn-mgr :as conn-mgr]))\n\n(client/get \"https://google.com\"\n            {:connection-manager\n             (conn-mgr/make-socks-proxied-conn-manager \"localhost\" 8081)})\n#+END_SRC\n\nIf your SOCKS connection requires a keystore / trust-store, you can specify that too:\n\n#+BEGIN_SRC clojure\n(ns foo.bar\n  (:require [clj-http.client :as client]\n            [clj-http.conn-mgr :as conn-mgr]))\n\n(client/get \"https://google.com\"\n            {:connection-manager\n             (conn-mgr/make-socks-proxied-conn-manager \"localhost\" 8081\n               {:keystore \"/path/to/keystore.ks\"\n                :keystore-type \"jks\" ; default: jks\n                :keystore-pass \"secretpass\"\n                :trust-store \"/path/to/trust-store.ks\"\n                :trust-store-type \"jks\" ; default jks\n                :trust-store-pass \"trustpass\"})})\n#+END_SRC\n\nYou can also store the proxied connection manager and reuse it later.\n\n** Custom Middleware\n:PROPERTIES:\n:CUSTOM_ID: h-c51cba6c-5c1b-4941-93c3-f769bb533562\n:END:\n\nSometime it is desirable to run a request with some middleware enabled and some\nleft out, the =with-middleware= method provides this functionality:\n\n#+BEGIN_SRC clojure\n(with-middleware [#'clj-http.client/wrap-method\n                  #'clj-http.client/wrap-url\n                  #'clj-http.client/wrap-exceptions]\n  (get \"http://example.com\")\n  (post \"http://example.com/foo\" {:body (.getBytes \"foo\")}))\n#+END_SRC\n\nTo see available middleware, check the =clj-http.client/default-middleware= var,\nwhich is a vector of the default middleware that clj-http uses.\n=clj-http.client/*current-middleware*= is bound to the current list of\nmiddleware during request time.\n\n** Modifying Apache-specific features of the =HttpClientBuilder= and =HttpAsyncClientBuilder=\n:PROPERTIES:\n:CUSTOM_ID: h:844f078c-531e-445e-b7ce-76092bcc9928\n:END:\n\nWhile clj-http tries to provide the features needed, there are times when it does not provide access\nto a parameter that you need. In these cases, you can use a couple of advanced parameters to provide\narbitrary configuration functions to be run on the =HttpClientBuilder= by specifying\n=:http-builder-fns= and =:async-http-builder-fns=.\n\nEach of these variables is a sequence of functions of two arguments, the http builder\n(=HttpClientBuilder= for =:http-builder-fns= and =HttpAsyncClientBuilder= for\n=:async-http-builder-fns=) and the request map.\n\n#+BEGIN_SRC clojure\n;; A function that takes a builder and disables Apache's cookie management\n(defun my-cookie-disabler [^HttpClientBuilder builder\n                           request]\n  (when (:disable-cookies request)\n    (.disableCookieManagement builder)))\n\n;; The functions to modify the builder are passed in\n(http/post \"http://www.example.org\" {:http-builder-fns [my-cookie-disabler]\n                                     :disable-cookies true})\n#+END_SRC\n\nThe functions are run in the order they are passed in (inside a =doseq=).\n\nBy specifying =:http-client-builder=, your own instance of\n=HttpClientBuilder= will be used. A supplied =HttpClientBuilder= which\nsets the connection manager, redirect strategy, retry handler, route\nplanner, cache, or cookie spec registry may find these overridden by\nclj-http's =:connection-manager=, =:redirect-strategy=,\n=:retry-handler=, =:cache=, or =:cookie-policy-registry= or\n=:cookie-spec=, respectively.\n\n** Incrementally JSON Parsing\n:PROPERTIES:\n:CUSTOM_ID: h:b01c16e8-7179-468e-8890-316939ec0e38\n:END:\n[[https://github.com/dakrone/cheshire][cheshire]] supports incrementally parsing JSON using lazy sequences. This approach can useful for\nprocessing large top-level JSON arrays because it doesn't require upfront work consuming the entire stream.\n\n#+begin_src clojure\n  (require '[cheshire.core :as json])\n\n  (defn print-all-pokemon-names [pokemons]\n    (for [pokemon pokemons]\n      (println (get-in pokemon [:name :english]))))\n\n  (let [url \"https://raw.githubusercontent.com/fanzeyi/pokemon.json/master/pokedex.json\"\n        response (get url {:as :reader})]\n    (with-open [reader (:body response)]  ; closes the underlying connection when we're done\n      (let [pokemons (json/parse-stream reader true)]\n        ; You must perform all reads from the stream inside `with-open`,\n        ; any , any lazy\n        (doall (print-all-pokemon-names pokemons)))))\n#+end_src\n\nKeep in mind that the =reader= object wraps a HTTP connection. The user needs to be aware of two\nthings:\n\n1. The user should close the reader after processing the stream, otherwise the underlying HTTP\n   Connection may leak and create subtle bugs. Clojure's [[https://clojuredocs.org/clojure.core/with-open][with-open]] is useful here.\n\n2. You should realize any lazy sequences before closing the connection. Use [[https://clojuredocs.org/clojure.core/doall][doall]] or [[https://clojure.org/reference/transducers][transducers]] to\n   prevent bugs from lazy IO. See [[https://stuartsierra.com/2015/08/25/clojure-donts-lazy-effects][Clojure Don'ts: Lazy Effects]].\n\nIn previous versions of =clj-http= (\u003c= 3.10.0), =clj-http= defaulted to lazily parsing JSON, but this\nwas slow and also confused users who didn't expect laziness.\n\n** DNS Resolution\n:PROPERTIES:\n:CUSTOM_ID: h:52CC15DF-57A5-425E-9AFC-10C9B4C4FA83\n:END:\n\nUsers may add their own DNS resolver function to override the default DNS Resolver. This is useful in situations where you are unable to change the name to IP Address mapping. It is analogous to the =--resolve= flag present in =curl=. This example uses =org.apache.http.impl.conn.InMemoryDnsResolver= to resolve =example.com= to IP Address =127.0.0.1=. \n\n#+BEGIN_SRC clojure\n(client/get \"https://example.com\" {:dns-resolver (doto (InMemoryDnsResolver.)\n                                                   (.add \"example.com\" (into-array[(InetAddress/getByAddress (byte-array [127 0 0 1]))])))})\n#+END_SRC\n\nThis option is supported for all of the connection managers.\n\nThe =dns-resolver= can be any instance of =DnsResolver=. Here is an example of a custom implementation that attempts to look up the hostname in the supplied map and falls back to the default SystemDnsResolver if not found. Note how IPV6 addresses are specified.\n\n#+BEGIN_SRC clojure\n(defn custom-dns-resolver\n  [host-map]\n  (let [system-dns-resolver (org.apache.http.impl.conn.SystemDefaultDnsResolver.)]\n    (reify\n      org.apache.http.conn.DnsResolver\n      (^\"[Ljava.net.InetAddress;\" resolve [this ^String host]\n       (if-let [address (get host-map host)]\n         (into-array [(java.net.InetAddress/getByAddress host (byte-array address))])\n         (.resolve system-dns-resolver host))))))\n       \n(client/get \"https://example.com\" {:dns-resolver (custom-dns-resolver {\"example.com\" [127 0 0 1]\n                                                                        \"www.google.com\" [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]})})\n#+END_SRC\n       \n\n* Development\n:PROPERTIES:\n:CUSTOM_ID: h-65bbf017-2e8b-4c43-824b-24b89cc27a70\n:END:\n\nPlease send a pull request or open an issue if you have any problems. See =CONTRIBUTING.md= for more\ninformation.\n\n** Faking Responses\n:PROPERTIES:\n:CUSTOM_ID: h-c3d9c7e0-cc3f-47bf-91e3-b12567b08eb6\n:END:\n\nIf you need to fake clj-http responses (for things like testing and such), check\nout the [[https://github.com/myfreeweb/clj-http-fake][clj-http-fake]] library.\n\n** Optional Dependencies\n:PROPERTIES:\n:CUSTOM_ID: h-f1fbdad3-cf40-41e0-8ae0-8716419be228\n:END:\n\nIn 2.0.0+ clj-http's optional dependencies at excluded by default, in order to\nuse the features you will need to add them to your =project.clj= file.\n\nclj-http currently has four optional dependencies, =cheshire=, =crouton=,\n=tools.reader= and =ring/ring-codec=. Any number of them may be included by\nadding them with the clj-http dependency in your project.clj:\n\n#+BEGIN_SRC clojure\n;; optional dependencies\n[cheshire] ;; for :as :json\n[crouton] ;; for :decode-body-headers\n[org.clojure/tools.reader] ;; for :as :clojure\n[ring/ring-codec] ;; for :as :x-www-form-urlencoded\n[com.cognitect/transit-clj] ;; for transit support\n#+END_SRC\n\nPrior to 2.0.0, you can /exclude/ the dependencies and clj-http will work\nwithout them.\n\n** clj-http-lite\n:PROPERTIES:\n:CUSTOM_ID: h-ba6b263b-74a5-40f3-afc1-b0d785554c2b\n:END:\n\nLike clj-http but need something more lightweight without as any external\ndependencies? Check out [[https://github.com/clj-commons/clj-http-lite][clj-http-lite]] for a project that can be used as a\ndrop-in replacement for clj-http.\n\n** Troubleshooting\n:PROPERTIES:\n:CUSTOM_ID: h-c543201e-a0e5-4e84-8eb2-6bf3e21a3140\n:END:\n*** VerifyError class org.codehaus.jackson.smile.SmileParser overrides final method getBinaryValue...\n:PROPERTIES:\n:CUSTOM_ID: h-c3a8ebc3-a247-4327-8b71-0097d1380873\n:END:\n\nThis is actually caused by your project attempting to use [[https://github.com/mmcgrana/clj-json/][clj-json]] and [[https://github.com/dakrone/cheshire][cheshire]]\nin the same classloader. You can fix the issue by either not using clj-json (and\nthus choosing cheshire), or specifying an exclusion for clj-http in your project\nlike this:\n\n#+BEGIN_SRC clojure\n(defproject foo \"0.1.0-SNAPSHOT\"\n  :dependencies [[org.clojure/clojure \"1.3.0\"]\n                 [clj-http \"0.3.4\" :exclusions [cheshire]]])\n#+END_SRC\n\nNote that if you exclude cheshire, json decoding of response bodies\nand json encoding of form-params cannot happen, you are responsible\nfor your own encoding/decoding.\n\nAs of clj-http 0.3.5, you should no longer see this, as Cheshire 3.1.0\nand clj-json can now live together without causing problems.\n\n*** NoHttpResponseException ... due to stale connections**\n:PROPERTIES:\n:CUSTOM_ID: h-9d7cf050-ed5b-4d23-8b02-97a9b9c94737\n:END:\n\nPersistent connections kept alive by the connection manager become stale: the\ntarget server shuts down the connection on its end without HttpClient being able\nto react to that event, while the connection is being idle, thus rendering the\nconnection half-closed or 'stale'.\n\nThis can be solved by using (with-connection-pool) as described in the\n'Using Persistent Connection' section above.\n\n* Tests\n:PROPERTIES:\n:CUSTOM_ID: h-a52feb3d-d966-4287-a07e-ad7aa7918fd5\n:END:\n\nTo run the tests:\n\n#+BEGIN_SRC\n$ lein deps\n$ lein test\n\nRun all tests (including integration):\n$ lein test :all\n\nRun tests against all clojure versions\n$ lein all test\n$ lein all test :all\n#+END_SRC\n\n* Testimonials\n:PROPERTIES:\n:CUSTOM_ID: h-3044d1f7-6772-43c2-9ded-8c71c7f9ada2\n:END:\n\nWith over [[https://clojars.org/clj-http][three million]] downloads, clj-http is a widely used, battle-tested clojure library. It is\nalso included in other libraries (like database clients) as a low-level http wrapper.\n\nLibraries using clj-http:\n\n- [[https://github.com/mattrepl/clj-oauth][clj-oauth]]\n- [[https://github.com/clojurewerkz/elastisch][elasticsearch]]\n- [[https://github.com/olauzon/capacitor][influxdb]]\n\nLibraries inspired by clj-http:\n\n- [[https://github.com/mpenet/jet][jet]]\n- [[https://github.com/clj-commons/clj-http-lite][clj-http-lite]]\n\n* Other Libraries Providing Middleware\n:PROPERTIES:\n:CUSTOM_ID: other-middleware\n:END:\n\n- [[https://github.com/sharetribe/aws-sig4][aws-sig4]] :: a pure clojure implementation of AWS v4 signature request signing as middleware\n\n(feel free to open a PR or issue if you'd like to add middleware here)\n\n* License\n:PROPERTIES:\n:CUSTOM_ID: h-2de3db75-7a1b-42b8-ad3b-6ef27fc2a5ea\n:END:\n\nReleased under the MIT License:\n\u003chttp://www.opensource.org/licenses/mit-license.php\u003e\n\n# Local Variables:\n# fill-column: 100\n# End:\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdakrone%2Fclj-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdakrone%2Fclj-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdakrone%2Fclj-http/lists"}