从 Network.HTTP.Enumerator 迁移到 Network.HTTP.Conduit
我不知道为什么我的代码会崩溃。起初我以为这是因为 parseURL
为 requestHeaders
提供了 []
。好吧,也许我只需要告诉它 resquestHeaders 应该是什么。好吧,我检查了从我的旧工作代码生成的 requestHeaders
。它也返回一个 []
。所以现在我没有主意了。下面是旧的工作代码,遵循我在 GHCi 中尝试使用基于新管道的库的事情。
captureRawJson :: IO Response
captureRawJson = do
nManager <- newManager
jRequest <- parseUrl url :: (IO (Request IO))
jResponse <- httpLbsRedirect jRequest nManager
closeManager nManager
return jResponse
上面的工作正常,这是我在迁移时一直尝试做的事情,以及我收到的错误。
Prelude Network.HTTP.Conduit> nManager <- newManager def
Prelude Network.HTTP.Conduit> jRequest <- parseUrl "https://10.69.69.1/cgi-bin/qaLinkEditor.cgi?json=1" :: (IO (Request IO))
Prelude Network.HTTP.Conduit> let response = httpLbs jRequest nManager
Prelude Network.HTTP.Conduit Control.Monad.Trans.Resource> runResourceT response
*** Exception: error unexpected packet: Handshake [ServerHelloDone]
正如您所看到的,它几乎是完全相同的代码。因此,我希望获得关于发生了哪些变化以及我应该更仔细地关注哪些内容的反馈。另外,如何检查在客户端代码和服务器之间来回发送的 http 标头?
I don't know why my code breaks. At first I thought it was because parseURL
gives []
for the requestHeaders
. Okay, so maybe I just need to tell it what the resquestHeaders should be. Well, I examined the requestHeaders
generated from my old, working code. It too, returns a []
. So now I am out of ideas. Below is the old working code, followed my things I have been trying in GHCi with with new conduits based library.
captureRawJson :: IO Response
captureRawJson = do
nManager <- newManager
jRequest <- parseUrl url :: (IO (Request IO))
jResponse <- httpLbsRedirect jRequest nManager
closeManager nManager
return jResponse
the above works fine, here's what I have been trying to do while migrating, and the error I receive.
Prelude Network.HTTP.Conduit> nManager <- newManager def
Prelude Network.HTTP.Conduit> jRequest <- parseUrl "https://10.69.69.1/cgi-bin/qaLinkEditor.cgi?json=1" :: (IO (Request IO))
Prelude Network.HTTP.Conduit> let response = httpLbs jRequest nManager
Prelude Network.HTTP.Conduit Control.Monad.Trans.Resource> runResourceT response
*** Exception: error unexpected packet: Handshake [ServerHelloDone]
So as you can see, it's almost exactly the same code. So I would like feedback on what has changed, and what I should be looking at more closely. Also, how can I examine the http headers being sent back and forth between my client code and the server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这个问题可以通过 tls 包中的一些更改来解决。我刚刚发布了http-conduit 1.2.5,请看一下是否解决了问题。
如果您仍然收到错误消息,则可能是 SSL 证书与您要连接的主机名不匹配。
I believe this was solved with some changes in the tls packages. I just released http-conduit 1.2.5, please have a look and see if it solves the problem.
If you still get an error message, it could be that the SSL cert doesn't match the hostname you're connecting to.