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 411 forks source link

Async clj-http.client/request causes Class cast exception #520

Closed peter-wilkins closed 2 years ago

peter-wilkins commented 5 years ago

Hi, I might be missing something. this works:

@(clj-http.client/get "https://www.github.com"
          {:async? true}
          #(%)
          #(%))

but this errors:

@(clj-http.client/request {:url "http://www.google.com"
               :method :get
               :async? true
               :respond #(%)
               :raise #(%)})

java.lang.ClassCastException: org.apache.http.impl.nio.client.FutureWrapper cannot be cast to clojure.lang.Associativejava.lang.ClassCastException: org.apache.http.impl.nio.client.FutureWrapper cannot be cast to clojure.lang.Associative at clojure.lang.RT.assoc (RT.java:823) clojure.core$assoc__5401.invokeStatic (core.clj:191) clojure.core/assoc (core.clj:190) clj_http.client$request_timing_response.invokeStatic (client.clj:1073) clj_http.client$request_timing_response.invoke (client.clj:1071) clj_http.client$wrap_request_timing$fn__6094.invoke (client.clj:1083)

rdivyanshu commented 5 years ago

Hi, correct way to call client/request with respond and raise handler is

@(clj-http.client/request  
      {:url "http://www.google.com"
       :method :get
      :async? true} 
      #(%) 
      #(%))

This part of documentation seems to be wrong. It seems, it was meant for request* not request

  * :async?
  * :respond
  * :raise