From 53e4c659682264321e5339615c7a1c6158f8aa6d Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Tue, 23 Jun 2015 17:03:01 +0000 Subject: [PATCH] fix Issue 14712 - GIT HEAD : std.net.curl regressions --- std/net/curl.d | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/std/net/curl.d b/std/net/curl.d index 3848ecf56db..020b5925c57 100644 --- a/std/net/curl.d +++ b/std/net/curl.d @@ -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 @@ -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.