Skip to content
This repository has been archived by the owner on Jul 24, 2018. It is now read-only.

Unexpected nested form-params treatment #15

Open
martinklepsch opened this issue Jun 5, 2018 · 0 comments
Open

Unexpected nested form-params treatment #15

martinklepsch opened this issue Jun 5, 2018 · 0 comments

Comments

@martinklepsch
Copy link

I bumped into something unexpected when switching from aleph to clj-http-lite. For some reason nested form params are sent differently despite their respective generate-query-string functions returning identical values.

The REPL session below makes this fairly easy to see by using httpbin.org:

;; boot -d aleph -d clj-http-lite repl

(def fp {"map" {"key1" "a", "key2" "b"}})

(require 'clj-http.lite.client 'aleph.http)

(= (aleph.http.client-middleware/generate-query-string fp)
   (clj-http.lite.client/generate-query-string fp))

(-> (clj-http.lite.client/post (str "https://httpbin.org/anything") {:accept "application/json" :form-params fp})
    :body cheshire.core/parse-string clojure.pprint/pprint)

(-> @(aleph.http/post (str "https://httpbin.org/anything") {:accept "application/json" :form-params fp})
    :body byte-streams/to-string cheshire.core/parse-string clojure.pprint/pprint)

If you manually account for the nesting as below things work as expected:

(def fp {"map[key1]" "a"
         "map[key2]" "b"})

It's fine to do the above but I'm just confused how :body is set to the same value that aleph would use in wrap-form-params and yet what is sent is somehow different.

@martinklepsch martinklepsch changed the title Unexpected form-params treatment Unexpected nested form-params treatment Jun 5, 2018
martinklepsch added a commit to cljdoc/cljdoc that referenced this issue Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant