dakrone / clj-http

An idiomatic clojure http client wrapping the apache client. Officially supported version.
http://clojars.org/clj-http
MIT License
1.78k stars 408 forks source link

{:async? true} ignored when making a request #553

Closed 0xtmphey closed 4 years ago

0xtmphey commented 4 years ago

Hello folks!

Maybe I'm doing something wrong but when I try to make an async request, it ignores async? option, blocks and returns response map directly instead of calling callbacks.

[clj-http "3.10.1"]

Making a request from readme:

(http/get "http://example.com"
            {:async? true}
            ;; respond callback
            (fn [response] (println "response is:" response))
            ;; raise callback
            (fn [exception] (println "exception message is: " (.getMessage exception))))

Here is the response:

{:status 200,
 :headers
 {"X-Cache" "HIT",
  "Server" "ECS (dcb/7EEA)",
  "Age" "277711",
  "Content-Type" "text/html; charset=UTF-8",
  "Content-Length" "648",
  "Connection" "close",
  "Accept-Ranges" "bytes",
  "Expires" "Mon, 17 Aug 2020 03:55:28 GMT",
  "Etag" "\"3147526947\"",
  "Date" "Mon, 10 Aug 2020 03:55:28 GMT",
  "Vary" "Accept-Encoding",
  "Last-Modified" "Thu, 17 Oct 2019 07:18:26 GMT",
  "Cache-Control" "max-age=604800"},
 :body "... some html content ...",
 :request-time 450,
 :trace-redirects ["http://example.com"],
 :orig-content-encoding "gzip"}

P.S. I'm making this request from CIDER repl

0xtmphey commented 4 years ago

False alarm :) For some reason previous version was cached or something like this and it was not using the right .jar