Skip to content

Commit 274b973

Browse files
deprecate Base.download in favor of Downloads.download (#37611)
bump LibCURL to version that doesn't use Base.download
1 parent 9b39974 commit 274b973

File tree

8 files changed

+66
-48
lines changed

8 files changed

+66
-48
lines changed

base/download.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ specified, a temporary path. Returns the path of the downloaded file.
2626
directly instead of calling this.
2727
"""
2828
function download(url::AbstractString, path::AbstractString)
29+
depwarn("Base.download is deprecated; use Downloads.download instead", :download)
2930
invokelatest(Downloads().download, download_url(url), path)
3031
end
3132
function download(url::AbstractString)
33+
depwarn("Base.download is deprecated; use Downloads.download instead", :download)
3234
invokelatest(Downloads().download, download_url(url))
3335
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fef32b47cbe021f75a46e6e1b22ace08
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dad23bd98d002ccbb5a0aa793eb1d5d7b6257fa1a517ebd366a4ee7addf8d2e0713135fc3a264d11b58a7c32ae65bddc34c58d3cabe92aa81ea57e9601a33110

stdlib/LibCURL.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
LIBCURL_BRANCH = master
2-
LIBCURL_SHA1 = 70aa2cc3f8fa4488897136a0a700b5425bfffdfa
2+
LIBCURL_SHA1 = 685a4697178415726f1f73d5ccedbc4ed1b5c2ac

test/download.jl

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,6 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
# Test that `Base.download_url()` is altered by `Base.DOWNLOAD_HOOKS`.
4-
let urls = ["http://httpbin.julialang.org/ip", "https://httpbin.julialang.org/ip"]
5-
for url in urls
6-
@test Base.download_url(url) == url
7-
end
8-
push!(Base.DOWNLOAD_HOOKS, url->replace(url, r"^http://" => "https://"))
9-
for url in urls
10-
@test Base.download_url(url) == urls[end]
11-
end
12-
pop!(Base.DOWNLOAD_HOOKS)
13-
for url in urls
14-
@test Base.download_url(url) == url
15-
end
16-
end
17-
18-
mktempdir() do temp_dir
19-
# Download a file
20-
file = joinpath(temp_dir, "ip")
21-
@test download("https://httpbin.julialang.org/ip", file) == file
22-
@test isfile(file)
23-
@test !isempty(read(file))
24-
ip = read(file, String)
25-
26-
# Test download rewrite hook
27-
push!(Base.DOWNLOAD_HOOKS, url->replace(url, r"/status/404$" => "/ip"))
28-
@test download("https://httpbin.julialang.org/status/404", file) == file
29-
@test isfile(file)
30-
@test !isempty(read(file))
31-
@test ip == read(file, String)
32-
pop!(Base.DOWNLOAD_HOOKS)
33-
34-
# Download an empty file
35-
empty_file = joinpath(temp_dir, "empty")
36-
@test download("https://httpbin.julialang.org/status/200", empty_file) == empty_file
37-
38-
# Windows and older versions of curl do not create the empty file (https://github.com/curl/curl/issues/183)
39-
@test !isfile(empty_file) || isempty(read(empty_file))
40-
41-
# Make sure that failed downloads do not leave files around
42-
missing_file = joinpath(temp_dir, "missing")
43-
@test_throws ErrorException download("https://httpbin.julialang.org/status/404", missing_file)
44-
@test !isfile(missing_file)
45-
46-
# Use a TEST-NET (192.0.2.0/24) address which shouldn't be bound
47-
invalid_host_file = joinpath(temp_dir, "invalid_host")
48-
@test_throws ErrorException download("http://192.0.2.1", invalid_host_file)
49-
@test !isfile(invalid_host_file)
3+
cmd = `$(Base.julia_cmd()) --depwarn=no --startup-file=no download_exec.jl`
4+
if !success(pipeline(cmd; stdout=stdout, stderr=stderr))
5+
error("download test failed, cmd : $cmd")
506
end

test/download_exec.jl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
module TestDownload
4+
5+
using Test
6+
7+
# Test that `Base.download_url()` is altered by `Base.DOWNLOAD_HOOKS`.
8+
let urls = ["http://httpbin.julialang.org/ip", "https://httpbin.julialang.org/ip"]
9+
for url in urls
10+
@test Base.download_url(url) == url
11+
end
12+
push!(Base.DOWNLOAD_HOOKS, url->replace(url, r"^http://" => "https://"))
13+
for url in urls
14+
@test Base.download_url(url) == urls[end]
15+
end
16+
pop!(Base.DOWNLOAD_HOOKS)
17+
for url in urls
18+
@test Base.download_url(url) == url
19+
end
20+
end
21+
22+
mktempdir() do temp_dir
23+
# Download a file
24+
file = joinpath(temp_dir, "ip")
25+
@test download("https://httpbin.julialang.org/ip", file) == file
26+
@test isfile(file)
27+
@test !isempty(read(file))
28+
ip = read(file, String)
29+
30+
# Test download rewrite hook
31+
push!(Base.DOWNLOAD_HOOKS, url->replace(url, r"/status/404$" => "/ip"))
32+
@test download("https://httpbin.julialang.org/status/404", file) == file
33+
@test isfile(file)
34+
@test !isempty(read(file))
35+
@test ip == read(file, String)
36+
pop!(Base.DOWNLOAD_HOOKS)
37+
38+
# Download an empty file
39+
empty_file = joinpath(temp_dir, "empty")
40+
@test download("https://httpbin.julialang.org/status/200", empty_file) == empty_file
41+
42+
# Windows and older versions of curl do not create the empty file (https://github.com/curl/curl/issues/183)
43+
@test !isfile(empty_file) || isempty(read(empty_file))
44+
45+
# Make sure that failed downloads do not leave files around
46+
missing_file = joinpath(temp_dir, "missing")
47+
@test_throws ErrorException download("https://httpbin.julialang.org/status/404", missing_file)
48+
@test !isfile(missing_file)
49+
50+
# Use a TEST-NET (192.0.2.0/24) address which shouldn't be bound
51+
invalid_host_file = joinpath(temp_dir, "invalid_host")
52+
@test_throws ErrorException download("http://192.0.2.1", invalid_host_file)
53+
@test !isfile(invalid_host_file)
54+
end
55+
56+
end # module

test/file.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ if !Sys.iswindows() || (Sys.windows_version() >= Sys.WINDOWS_VISTA_VER)
12051205
else
12061206
@test_throws ErrorException symlink(file, "ba\0d")
12071207
end
1208+
using Downloads: download
12081209
@test_throws ArgumentError download("good", "ba\0d")
12091210
@test_throws ArgumentError download("ba\0d", "good")
12101211

test/spawn.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
###################################
66

77
using Random, Sockets
8+
using Downloads: download
89

910
valgrind_off = ccall(:jl_running_on_valgrind, Cint, ()) == 0
1011

0 commit comments

Comments
 (0)