Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
peter-wilkins opened this issue Oct 9, 2019 · 1 comment · May be fixed by #526
Closed

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

peter-wilkins opened this issue Oct 9, 2019 · 1 comment · May be fixed by #526

Comments

@peter-wilkins
Copy link

Hi, I might be missing something.
this works:

@(clj-http.client/get "https://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
Copy link

rdivyanshu commented Oct 10, 2019

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

rymndhng added a commit that referenced this issue May 16, 2020
Ensures arguments for request & method-functions (get/put/post etc.) have
similarly.

Fixes #520.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants