Last active
May 10, 2018 14:09
-
-
Save jhrcek/1247d436ccb6d074ac553489ca59d9e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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