开发者

Download a file in D

开发者 https://www.devze.com 2023-03-29 01:39 出处:网络
How do I download a file in D? I have checked out the standard library, and the sample. I would rather use开发者_如何学Go phobos with the newest dmd2 than tango. All I need to do is download a file (h

How do I download a file in D? I have checked out the standard library, and the sample. I would rather use开发者_如何学Go phobos with the newest dmd2 than tango. All I need to do is download a file (hopefully using std.socket and std.socketstream). Could also use etc.c.curl.


etc.c.curl provides the C bindings for curl, so you could use that. That's really the only way that I know of to do it using Phobos at the moment, unless you want to do it with std.socket and handle the HTTP requests and responses yourself (which I assume that you don't really want to do).

However, a D wrapper for the C curl bindings is currently in review in the digitalmars.D newsgroup, which would give you a D API for interacting with curl. Assuming that it passes review (which it probably will, though it may change a fair bit during the review process), it'll end up in Phobos. Once it's merged in, it'll be in the following release. So, it'll probably be in either 2.055 or 2.056, depending on when 2.055 gets released.

Until then, however, you're pretty much going to need to either use the C bindings or download the D curl wrapper currently under review. You can find the documentation here and the code here if you want to try it out. If you do that however, it would be much appreciated if you chimed in on the review in the newsgroup to give feedback on it so that it can be appropriately ironed out and improved prior to inclusion in Phobos.

0

精彩评论

暂无评论...
验证码 换一张
取 消