D 相当于 XMLHttpRequest 函数
我正在寻找一个在 D 中发出 http 请求的示例代码,例如 jscript 的 XMLHttpRequest 的方式。
I am looking for an example code to make an http request in D, something how the XMLHttpRequest of jscript.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有些人为 libcurl 创建了包装器,您可以使用它来发出 http 请求。
试试这个。 https://github.com/gmfawcett/d-play -libcurl/blob/master/fawcett/curl.d
Some people have created wrappers for libcurl, which you can use to make http requests.
Try this one. https://github.com/gmfawcett/d-play-libcurl/blob/master/fawcett/curl.d
我不知道任何 D 库具有此类功能,尽管可能有人编写过一个。标准库中肯定还没有任何 HTTP 的东西。它很可能在某个时候进入那里,但 D 的标准库 - Phobos - 仍然相当年轻。特定领域的东西肯定还不存在。
因此,要么您需要能够找到某人已经编写的库,要么您需要自己编写它。但在 D 中还没有标准的方法来做到这一点。
I'm not aware of any D library that has that sort of functionality, though someone may have written one. There certainly isn't any HTTP anything in the standard library yet. It may very well get in there at some point, but D's standard library - Phobos - is still fairly young. Something that domain-specific certainly isn't in there yet.
So, either you'll need to be able to find a library that someone has already written, or you're going to need to write it yourself. But there is no standard way to do it in D yet.
标准库中的 std.net.curl
http://dlang.org/phobos/std_net_curl.html
(据我所知,自 2011 年以来情况发生了变化)
std.net.curl from standard library
http://dlang.org/phobos/std_net_curl.html
(as I understand situation changed since 2011)