从Network.HTTP.Enumerator迁移到Network.HTTP.Conduit [英] Migrating from Network.HTTP.Enumerator to Network.HTTP.Conduit
问题描述
我不知道我的代码为什么会中断。起初我以为这是因为 parseURL
给 []
用于 requestHeaders
。好的,也许我只需要告诉它resquestHeaders应该是什么。好吧,我检查了从我的旧有效代码生成的 requestHeaders
。它也返回一个 []
。所以现在我没有想法。下面是旧的工作代码,跟着我一直在GHCi尝试的新事物,使用基于库的新导管。
captureRawJson :: IO Response
captureRawJson = do
nManager< - newManager
jRequest< - parseUrl url ::(IO(请求IO))
jResponse< - httpLbsRedirect jRequest nManager
closeManager nManager
return jResponse
上面的工作正常,这是我一直在尝试的
Prelude Network.HTTP.Conduit> nManager< - newManager def
Prelude Network.HTTP.Conduit> jRequest< - parseUrlhttps://10.69.69.1/cgi-bin/qaLinkEditor.cgi?json=1::(IO(请求IO))
Prelude Network.HTTP.Conduit> let response = httpLbs jRequest nManager
Prelude Network.HTTP.Conduit Control.Monad.Trans.Resource> runResourceT响应
***异常:错误意外数据包:Handshake [ServerHelloDone]
你可以看到,它几乎是完全一样的代码。所以我希望反馈意见是什么改变了,我应该更仔细地看待。另外,我该如何检查在我的客户端代码和服务器之间来回发送的http头文件? 我相信这个解决了tls包中的一些变化。我刚刚发布了http-conduit 1.2.5,请看看它是否可以解决问题。
如果您仍然收到错误消息,可能是SSL证书与您连接的主机名不匹配。
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?
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.
这篇关于从Network.HTTP.Enumerator迁移到Network.HTTP.Conduit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!