Skip to content

Commit

Permalink
Merge pull request #3436 from CyberShadow/pull-20150623-170241
Browse files Browse the repository at this point in the history
fix Issue 14712 - GIT HEAD : std.net.curl regressions
  • Loading branch information
schveiguy committed Jun 23, 2015
2 parents 693bf11 + 53e4c65 commit 04494ce
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions std/net/curl.d
Expand Up @@ -291,8 +291,8 @@ void download(Conn = AutoProtocol)(const(char)[] url, string saveToPath, Conn co
{
import std.stdio : File;
conn.url = url;
auto f = File(saveToPath, "w");
conn.onReceive = (ubyte[] data) { f.write(data); return data.length; };
auto f = File(saveToPath, "wb");
conn.onReceive = (ubyte[] data) { f.rawWrite(data); return data.length; };
conn.perform();
}
else
Expand All @@ -309,8 +309,11 @@ unittest
if (!netAllowed()) return;
// No anonymous DigitalMars FTP access as of 2015
//download("ftp.digitalmars.com/sieve.ds", buildPath(tempDir(), "downloaded-ftp-file"));
download("d-lang.appspot.com/testUrl1", buildPath(tempDir(), "downloaded-http-file"));
download!(HTTP)("d-lang.appspot.com/testUrl1", buildPath(tempDir(), "downloaded-http-file"));
auto fn = buildPath(tempDir(), "downloaded-http-file");
download("d-lang.appspot.com/testUrl1", fn);
assert(std.file.readText(fn) == "Hello world\n");
download!(HTTP)("d-lang.appspot.com/testUrl1", fn);
assert(std.file.readText(fn) == "Hello world\n");
}

/** Upload file from local files system using the HTTP or FTP protocol.
Expand Down

0 comments on commit 04494ce

Please sign in to comment.