使用runghc
:
import Network.HTTP
main = simpleHTTP (getRequest "https://stackoverflow.com")
>>= getResponseBody >>= putStrLn
我收到错误消息
printso.hs: user error (https not supported)
我不想切换到未加密的HTTP - 如何将Network.HTTP
与SSL / TLS一起使用?
答案 0 :(得分:6)
您无法直接执行此操作,例如请参阅this post。但是,您可以使用http-conduit
库中的Network.HTTP.Conduit
代替。
首先使用cabal install http-conduit
安装它。
然后您可以使用此代码(请注意,它与Network.HTTP
形成对比,它使用惰性ByteString
s)作为替代:
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as LB
main = simpleHttp "https://stackoverflow.com"
>>= LB.putStr
另一种方法是使用the Haskell libcurl binding,但这取决于原生libcurl。