{-# OPTIONS_GHC -XScopedTypeVariables #-} module Haste.Post ( post , PostParameter (..) , PostResponse (..) ) where import Haste.Types import Haste.Monad (liftIO) import Network.Curl hiding (URLString) data PostParameter = String :=> String data PostResponse = PostResponse { statusLine :: String , headers :: [(String, String)] , body :: String } post :: URLString -> [PostParameter] -> HM PostResponse post url params = liftIO $ do resp :: CurlResponse_ [(String, String)] String <- curlGetResponse_ url [CurlHttpPost $ map httpPost params] return PostResponse { statusLine = respStatusLine resp , headers = respHeaders resp , body = respBody resp } httpPost :: PostParameter -> HttpPost httpPost (k :=> v) = HttpPost k (Just "text/plain") (ContentString v) [] Nothing