Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

DFL , Tango, Download, Progressbar

Moderators: larsivi kris

Posted: 11/19/07 23:08:56

no matter what I do I can not get an HTTP/FTP client to download correctly and update the progress bar. I would like for someone to give a good example via post back on this forum of how to do such. I would like it to use a dmd compiler zip download as a download so that forces us to ftp. I need to know so I can continue D Installer In D. Any help would be appreciated and help that follows that above would be super/great/Word meaning something better than apreciated.

Lester L. Martin II

Lester L. Martin II

Author Message

Posted: 11/20/07 08:56:49

Hi Lester!

It is unclear if you are able to download the file at all? If you just try to download the file, not worrying about the progress bar for now, does it work? If not, could you post your program and any errors you get?

Posted: 11/20/07 09:05:13

Hello, Thankyou for the quick reply. I will try that on something(without the progress bar) and then repost. If it doesn't work I'll let you see how I did it. I would just post the source to all the downloader part that I created but I started over imediately after it didn't work.

Lester L. Martin II

Lester L. Martin II

Posted: 11/20/07 10:05:40

OK here comes the code. HTTP download works but ftp doesn't; I need ftp help.

this is the test file named download_test.d

import dinstaller.downloader; import;

int main() {

http_ftp_download n = new http_ftp_download();"", "projects//tango//0.99.3//", "C:\\"); Cout("finished tango").flush;"", "", "C://"); Cout("finished dmd"); return 0;


this is the class file containing the downloader named downloader.d

import; import; import; import tango.text.Util; import; import; import Integer = tango.text.convert.Integer;

public class http_ftp_download {

char[] file_placement; int downloaded;

void download(char[] host, char[] file_path, char[] path_to_place) {

file_placement = path_to_place; if(containsPattern(host, "ftp")) {

do_ftp_download(host, file_path);

} else

do_http_download(host ~ file_path);


void do_ftp_download(char[] host, char[] file_path) {

auto ftpc = new FTPConnection(host, "user"," pass", 21); ftpc.get(host ~ file_path, file_placement, null, FtpFormat?.image);


void do_http_download(char[] file) {

auto httpc = new HttpClient?(HttpClient?.Get, file);; if(httpc.isResponseOK) {

auto length = httpc.getResponseHeaders.getInt(HttpHeader?.ContentLength?, uint.max);, length);

} httpc.close();


void http_file_writer(void[] content) {

downloaded += content.length; Cout(Integer.toUtf8(downloaded)).newline; Cout.flush; File f = new File(file_placement); f.append(content);



this is the error you get from tango on ftp tango.core.Exception.AddressException?: Unable to resolve host ''

why doesn't this work.

Lester L. Martin II

Posted: 11/20/07 10:40:23

I am not very familiar with this part of Tango, but will look at it in a short while. Just need to finish off a few other things first.

Posted: 11/20/07 10:45:59

ok, thanks Larsivi

Lester L. Martin II

Posted: 11/20/07 10:58:47

Yay! I figured it out! FtpClient? doesn't want a protocol eg http://"$place".

So now it's working.

Lester L. Martin II