HTTP responses without content-type sometimes returned as Clojure HashMap

57 vues
Accéder directement au premier message non lu

Francis Hitchens

non lue,
11 sept. 2014, 12:14:2911/09/2014
à comp...@googlegroups.com
Hi,

I am receiving responses from a downstream server that have identical HTTP headers (neither have a content-type header). One message gets converted back to a proper HTTP response at the client by the compojure route, the other always returns to the client as a Clojure HashMap. I have tried (conj {:content-type :text/xml} response) but still I get a HashMap coming back.

Any ideas?

regards, Francis.

James Reeves

non lue,
12 sept. 2014, 13:44:4612/09/2014
à Compojure


On 12 Sep 2014 14:06, "Francis Hitchens" <fhit...@gmail.com> wrote:
> I am receiving responses from a downstream server that have identical HTTP headers (neither have a content-type header). One message gets converted back to a proper HTTP response at the client by the compojure route, the other always returns to the client as a Clojure HashMap.

What exactly do you mean by this? Could you provide a code sample?

- James

Francis Hitchens

non lue,
13 sept. 2014, 11:17:4213/09/2014
à comp...@googlegroups.com,ja...@booleanknot.com
Sure, sorry I was a bit vague.

What is happening is that the Clojure HashMap response I am getting back from clj-http.client/post is not getting converted at all to a proper HTTP response when seen by the curl client. 

This is the curl response...

{:content-type-params {} :content-type :text/html :body etc}

It's a valid clojure.lang.PersistentArrayMap and identical to what came back from the client/post call.

I must somehow have screwed up something in the defroutes macro that is bypassing the clojure to HTTP response conversion. I can't see it though. Looks identical to all other routes I have set up.

regards, Francis.

James Reeves

non lue,
14 sept. 2014, 10:24:0214/09/2014
à Compojure

You'll need to provide some code, I'm afraid. I can't think of anything obvious that would cause this.

--
You received this message because you are subscribed to the Google Groups "Compojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to compojure+...@googlegroups.com.
To post to this group, send email to comp...@googlegroups.com.
Visit this group at http://groups.google.com/group/compojure.
For more options, visit https://groups.google.com/d/optout.

Francis Hitchens

non lue,
15 sept. 2014, 12:23:1515/09/2014
à comp...@googlegroups.com,ja...@booleanknot.com
Ha, got it.

I had a 

(for [[env host] (get-host)]

Francis Hitchens

non lue,
15 sept. 2014, 12:29:2515/09/2014
à comp...@googlegroups.com,ja...@booleanknot.com
Ha, got it.

I had a 

(for [[env host] (get-hosts) :while (= env e) ]
  (do
     (log env)
     (post-to host)))

type of thing that I guess was returning the Clojure HashArray response plus a nil, causing me hours of confusion.

Regards, Francis.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message