I'm trying to use Wai and Warp to write a modest HTTP server, and I'm stuck trying to read the body of the POST / PUT request to retrieve the form parameters. When will I do the following
{-# LANGUAGE OverloadedStrings #-} import Network.Wai.Handler.Warp (run) import qualified Data.ByteString.Char8 as C import Network.Wai.Parse (parseRequestBody, lbsSink) import Network.Wai(Response(..)) import Network.HTTP.Types(status200) import Blaze.ByteString.Builder main = run 3000 app app req = do (params, _) <- parseRequestBody lbsSink req let r = C.concat $ map (\(x,y) -> C.concat [x,y]) params return $ ResponseBuilder status200 [("Content-Type", "text/plain")] $ fromByteString r
and then I try a simple query like
curl -o - -X POST http://localhost:3000/ -d name=toto
it shows that my parameters are not being transferred to another server, or rather, they are not receiving properly decoded data, since nothing is being returned.
source share