diff --git a/source/dub/internal/vibecompat/inet/urltransfer.d b/source/dub/internal/vibecompat/inet/urltransfer.d deleted file mode 100644 index c5ced6f..0000000 --- a/source/dub/internal/vibecompat/inet/urltransfer.d +++ /dev/null @@ -1,37 +0,0 @@ -/** - Downloading and uploading of data from/to URLs. - - Copyright: © 2012 RejectedSoftware e.K. - License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. - Authors: Sönke Ludwig -*/ -module dub.internal.vibecompat.inet.urltransfer; - -import dub.internal.vibecompat.core.log; -import dub.internal.vibecompat.core.file; -import dub.internal.vibecompat.inet.url; - -import std.exception; -import std.net.curl; -import std.string; - - -/** - Downloads a file from the specified URL. - - Any redirects will be followed until the actual file resource is reached or if the redirection - limit of 10 is reached. Note that only HTTP(S) is currently supported. -*/ -void download(string url, string filename) -{ - auto conn = HTTP(); - static if( is(typeof(&conn.verifyPeer)) ) - conn.verifyPeer = false; - std.net.curl.download(url, filename, conn); -} - -/// ditto -void download(Url url, Path filename) -{ - download(url.toString(), filename.toNativeString()); -} diff --git a/source/dub/packagesupplier.d b/source/dub/packagesupplier.d index 19559d2..bc60d12 100644 --- a/source/dub/packagesupplier.d +++ b/source/dub/packagesupplier.d @@ -12,7 +12,6 @@ import dub.internal.vibecompat.core.file; import dub.internal.vibecompat.data.json; import dub.internal.vibecompat.inet.url; -import dub.internal.vibecompat.inet.urltransfer; import dub.utils; import std.file; diff --git a/source/dub/registry.d b/source/dub/registry.d index 2c80cb6..21b7801 100644 --- a/source/dub/registry.d +++ b/source/dub/registry.d Binary files differ diff --git a/source/dub/utils.d b/source/dub/utils.d index 0222f40..8bb3b78 100644 --- a/source/dub/utils.d +++ b/source/dub/utils.d @@ -14,13 +14,14 @@ import dub.internal.vibecompat.inet.url; // todo: cleanup imports. -import std.array; -import std.file; -import std.exception; import std.algorithm; -import std.zip; -import std.typecons; +import std.array; import std.conv; +import std.exception; +import std.file; +import std.net.curl; +import std.typecons; +import std.zip; package bool isEmptyDir(Path p) { @@ -83,3 +84,24 @@ enforce(exitcode == 0, "Command failed with exit code "~to!string(exitcode)); } } + +/** + Downloads a file from the specified URL. + + Any redirects will be followed until the actual file resource is reached or if the redirection + limit of 10 is reached. Note that only HTTP(S) is currently supported. +*/ +void download(string url, string filename) +{ + auto conn = HTTP(); + static if( is(typeof(&conn.verifyPeer)) ) + conn.verifyPeer = false; + conn.addRequestHeader("User-Agent", "dub/0.7.13 (std.net.curl; +https://github.com/rejectedsoftware/dub)"); + std.net.curl.download(url, filename, conn); +} + +/// ditto +void download(Url url, Path filename) +{ + download(url.toString(), filename.toNativeString()); +}