cch1 / http.async.client

Async Http Client - Clojure
http://cch1.github.com/http.async.client
267 stars 40 forks source link

Example in 'Getting Started' fails with clojure 1.7 #62

Closed paulrd closed 9 years ago

paulrd commented 9 years ago

I using http.async.client 0.6.0 with clojure 1.7. I get the following error when I execute this code (returns nil):

(with-open [client (http/create-client)] ; Create client
  (let [response (http/GET client "http://github.com/neotyk/http.async.client/")] ; request http resource
    (-> response
        http/await     ; wait for response to be received
        http/string))) ; read body of response as string

(http/error *1):

  1. Unhandled java.lang.NullPointerException (No message)
                  core.clj: 7231  clojure.core/realized?
                client.clj:  195  http.async.client/failed?
                client.clj:  286  http.async.client/error

Problem seems to be with http/string as leaving that call out makes things ok.

paulrd commented 9 years ago

Oh nevermind, I wasn't using *1 properly. It has to be a response map - obviously! But there is still the strange issue of getting a nil body for github.com while google.ca works just fine. Perhaps there is something strange about github. It seems to be returning status :code 301 :msg "moved permanently" and :body of nil. In any case, you might want to put a different example in the getting started doc, or advise. Thanks!

paulrd commented 9 years ago

Haha! I found the problem. The getting started guide needs to change the github url from 'http://' to 'https://'! Then it works as advertised. :-/

cch1 commented 9 years ago

Thanks Paul!