r0man / oauth-clj

Clojure OAuth library
95 stars 27 forks source link

Allow use of non form-encoded payload #27

Open rukor opened 8 years ago

rukor commented 8 years ago

At the moment, it always tries to make the request entity part of the base string irrespective of the content-type; this obviously run into issues when it tries to parse the body. So I changed parse-body-params to:

(defn parse-body-params
  "Parse the body of `request` as an URL encoded parameter list."
  [request]
  (let [body (to-str (:body request))]
    (if (and (= x-www-form-urlencoded (:content-type request))
             (not (blank? body)))
      (-> (apply hash-map (split body #"[=&]"))
          (transform-values url-decode))
      {})))

I can send a pull request if you prefer.

Thanks, R

r0man commented 8 years ago

@rukor Sorry, was AFK for some days. Yes, I would prefer a PR with a test. :)