Migrating from Network.HTTP.Enumerator to Network.HTTP.Conduit

▼魔方 西西 提交于 2019-12-13 15:08:34

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/9154504/migrating-from-network-http-enumerator-to-network-http-conduit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!