 (ns fake-http.fake
   (:import (okhttp3.mockwebserver MockWebServer Dispatcher MockResponse RecordedRequest))
-  (:require [clojure.string :refer [split blank?]]))
+  (:require [clojure.string :refer [split blank? lower-case]]))
 
 (defn- index-of [coll item]
   "Get the index of an item in a collection"

      str
      (.substring str (inc index-of-after)))))

(defn map-vals [f m]
  "Maps the values in a map with the function f"
  (into {} (for [[k v] m] [k (f v)])))

(defn- keywordize-keys
  "Recursively transforms all map keys from strings to keywords."

                                            (.toMultimap)
                                            ; Create a clojure map of the multimap.
                                            ; The multimap contains a list as value and thus we map it to a clojure vector
                                            (map-kv lower-case vec))
                         :content-type (last (get :headers "content-type"))
                         :request-line (.getRequestLine request)
                         :path         (.getPath request)
                         :body         body
