解决Network.HTTP'用户错误(不支持https)' [英] Resolving Network.HTTP 'user error (https not supported)'
问题描述
使用 runghc
运行此Haskell程序时:
When running this Haskell program using runghc
:
import Network.HTTP
main = simpleHTTP (getRequest "https://stackoverflow.com")
>>= getResponseBody >>= putStrLn
我收到错误消息
printso.hs: user error (https not supported)
我不想切换到未加密的HTTP,如何使用 Network.HTTP
具有SSL/TLS?
I don't want to switch to unencrypted HTTP -- how can I use Network.HTTP
with SSL/TLS?
推荐答案
您不能直接这样做,例如,请参见 Network.代替来自
. http-conduit
库的HTTP.Conduit
You can't do that directly, see for example this post. However you could use Network.HTTP.Conduit
from the http-conduit
library instead.
首先使用 cabal install http-conduit
进行安装.
然后,您可以使用以下代码(请注意,它与 Network.HTTP
相对,它使用了懒惰的 ByteString
s)代替:
Then you can use this code (note that it contrast to Network.HTTP
it uses lazy ByteString
s) as a replacement:
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as LB
main = simpleHttp "https://stackoverflow.com"
>>= LB.putStr
另一种替代方法是使用 Haskell libcurl 绑定,具体取决于但是,在本地 libcurl 上.
Another alternative is to use the Haskell libcurl binding which depends on the native libcurl, however.
这篇关于解决Network.HTTP'用户错误(不支持https)'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!