gpt4 book ai didi

haskell - 正在解析网络.HTTP 'user error (https not supported)'

转载 作者:行者123 更新时间:2023-12-02 14:03:43 24 4
gpt4 key购买 nike

使用runghc运行此Haskell程序时:

import Network.HTTP

main = simpleHTTP (getRequest "https://stackoverflow.com")
>>= getResponseBody >>= putStrLn

我收到错误消息

printso.hs: user error (https not supported)

我不想切换到未加密的 HTTP - 我该如何使用 Network.HTTP使用 SSL/TLS?

最佳答案

您不能直接执行此操作,请参阅例如 this post 。但是您可以使用 Network.HTTP.Conduit来自 http-conduit 库。

首先使用cabal install http-conduit安装它。

然后您可以使用此代码(请注意,它与 Network.HTTP 不同,它使用惰性 ByteString)作为替换:

import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as LB

main = simpleHttp "https://stackoverflow.com"
>>= LB.putStr

另一种选择是使用the Haskell libcurl binding这取决于 native libcurl然而。

关于haskell - 正在解析网络.HTTP 'user error (https not supported)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21296606/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com