27 Jul 2011 11:46
Upgrade to Happstack 6 - request bodies
Hello all, We have some problems upgrading one of our server applications to Happstack 6, lots of things related to request bodies and request parameters have changed. Unfortunately, the new situation doesn't seem that straightforward to me. In the previous version of Happstack we were able to access the request body directly using the `rqBody` function. In the new situation we have to first decode the body using `decodeBody` and than access it by reading from an MVar. The utility functions accessing this variables ensure the body is only request once, all consecutive calls will error. We're pretty sure we're accessing the body only once and after decoding it, but we still get the following error: "askRqEnv failed because the request body has not been decoded yet. Try using 'decodeBody'." This happens when accessing the cookie using 'readCookieValue'. Isn't strange that accessing the cookie value uses the request body at all? So the pattern we use is: > do decodeBody (defaultBodyPolicy "/tmp/" (10 * 1024 * 1024) (10 * 1024 * 1024) (1024 * 1024)) > liftIO (print 1) > c <- lookCookieValue "tid" > liftIO (print 2) > b <- takeRequestBody > ... And the result is: > 1 > askRqEnv failed because the request body has not been decoded yet. Try using 'decodeBody'. (this happens using happstack-server-6.0.3, in 6.1.6 the same error string is sent to the client)(Continue reading)
RSS Feed