Fork me on GitHub
#ring
<
2019-02-22
>
mdrago102602:02:13

Hi guys, quick question. Is there any with ring/compojure to read the raw body of a request that is application/x-www-form-urlencoded No matter what I do, even when I remove all middleware it's always a map

mdrago102602:02:42

I need the raw request to do a an hmac digest on it to verify the request

mdrago102602:02:22

I thought about using (ring.util.codec/url-encode payload) but obviously these maps aren't ordered

seancorfield03:02:21

@mdrago1026 I'm pretty sure the answer is "no" because by the time Ring has passed you the request, it has already been read and decoded -- and not all servers allow the raw body of a request to be read twice, as I recall...

mdrago102603:02:05

Yeah, i believe you are right, which is unfortunate. Still digging in to it. It's weird, even if I intercept the BytesInputStream and slurp it, it already seems to be a map

mdrago102603:02:58

For what it's worth, I found a workaround. I'm using http-kit. Before I hand the request off to any of my compojure handlers, I'm consuming the :body of the request. At this point it is still in the "raw" form. I just assoc it to the request as a different key, then pass on to the handlers. Not pretty, but it works

5