问题
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