How do I construct a Network.HTTP.Conduit.Request object?

可紊 提交于 2019-12-14 03:56:19

问题


Trying to construct a Request with Network.HTTP.Conduit package. The instructions are:

The constructor for this data type is not exposed. Instead, you should use either the def method to retrieve a default instance, or parseUrl to construct from a URL, and then use the records below to make modifications...

I have no idea what this means. How can I "make modifications" to an immutable Request object; furthermore none of the functions "below" return a Request object!

This is as far as I got:

main = do
    let req = def :: String
    putStrLn "What now? How do I make it a POST?"

Although I am not sure why I used String above either.

Any help appreciated.


回答1:


It's not at all clear from the documentation, but the "functions below" are actually record labels, so you can use record update syntax to construct the request you want. Of course "modify" here means creating a new request based on the default one, not an actual destructive update.

In other words, something like this:

let req = def { method = methodPost, ... }


来源:https://stackoverflow.com/questions/9995461/how-do-i-construct-a-network-http-conduit-request-object

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