Skip to content

Instantly share code, notes, and snippets.

@caiorss
Created November 20, 2016 03:57
Show Gist options
  • Save caiorss/659502fd588b203bdeaf4d5f9281d3bb to your computer and use it in GitHub Desktop.
Save caiorss/659502fd588b203bdeaf4d5f9281d3bb to your computer and use it in GitHub Desktop.
http.conduit.post.hs
{-# LANGUAGE OverloadedStrings #-}
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy.Char8 as L
main :: IO ()
main = do
plainRequest <- parseUrl "http://httpbin.org/post"
let enrichedRequest = urlEncodedBody [("foo","bar"),("baz","qux")] plainRequest
response <- withManager $ httpLbs enrichedRequest
putStrLn $ show enrichedRequest
print $ responseStatus response
mapM_ print $ responseHeaders response
L.putStrLn $ responseBody response
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment