我如何构建Network.HTTP.Conduit.Request对象? [英] How do I construct a Network.HTTP.Conduit.Request object?

查看:111
本文介绍了我如何构建Network.HTTP.Conduit.Request对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试用 Request /html/Network-HTTP-Conduit.html#t%3aRequestrel =nofollow> Network.HTTP.Conduit 包。这些指令是:


此数据类型的构造函数未公开。相反,您应该
使用 def 方法来检索默认实例,或 parseUrl
从URL构建,然后使用下面的记录进行
修改...


我不知道这是什么意思。我如何修改一个不可变的Request对象;此外,没有一个函数返回请求对象!



这是据我所知:

  main = do 
let req = def :: String
putStrLn现在是什么?我如何使它成为POST?

尽管我不确定为什么使用 String



任何帮助表示赞赏。

解决方案

完全可以从文档中明白,但下面的函数实际上是记录标签,所以您可以使用记录更新语法来构建您想要的请求。当然,这里的修改意味着创建一个基于默认的新请求,而不是实际的破坏性更新。



换句话说,就是这样的:

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


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.

解决方案

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, ... }

这篇关于我如何构建Network.HTTP.Conduit.Request对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆