For information @cgrand, this fn
work with aws examples
(defn req-text->req-map-revisited [req]
(let [[_ request-method full-uri protocol headers+body] (re-find #"(?s)([A-Z]+)\s(.+)\s(HTTP/1\.1)\n(.*)" req)
headers (for [[_ header value] (re-seq #"(?s)(\S+):(.*?\n(?:[\t ].*?\n)*)" (str headers+body "\n"))]
[header (s/trim-newline value)])
body (re-find #"Param1=value1" headers+body)
[_ uri query-string] (re-find #"(?s)([\S&&[^?]]+)\??(\S+)?" full-uri)]
(cond->
{:request-method request-method
:uri full-uri
:protocol protocol}
(not (or (empty? headers) (nil? headers))) (assoc :headers
(into {}
(x/by-key (comp (interpose ",")
x/str))
headers))
(not (nil? body)) (assoc :body body)
(not (nil? query-string)) (assoc :query-string query-string :uri uri)
true (as->
req-map
(assoc req-map :server-name (get-in req-map [:headers "Host"]))
(update req-map :headers dissoc "Host")))))
I am not the best at regex but at least it does format the way sigv4
needs request
now I am going to try to make tests pass 😄
👍 for tests