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

Unexpected nested form-params treatment #15

@martinklepsch

Description

@martinklepsch

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions