Skip to content

Instantly share code, notes, and snippets.

@jhrcek
Last active May 10, 2018 14:09
Show Gist options
  • Save jhrcek/1247d436ccb6d074ac553489ca59d9e3 to your computer and use it in GitHub Desktop.
Save jhrcek/1247d436ccb6d074ac553489ca59d9e3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env stack
-- stack script --resolver lts-10.8 --package http-client-tls,http-conduit,bytestring
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy.Char8 as L8
import Network.HTTP.Client.TLS (setGlobalManager)
import Network.HTTP.Conduit (newManager, tlsManagerSettings)
import Network.HTTP.Simple (getResponseBody, getResponseHeader,
getResponseStatusCode, httpLBS,
setRequestManager)
main :: IO ()
main = do
newManager tlsManagerSettings >>= setGlobalManager
response <- httpLBS "https://httpbin.org/get"
putStrLn $ "The status code was: " ++
show (getResponseStatusCode response)
print $ getResponseHeader "Content-Type" response
L8.putStrLn $ getResponseBody response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment