|
1 | 1 | # This file is a part of Julia. License is MIT: https://julialang.org/license
|
2 | 2 |
|
3 |
| -let urls = ["http://httpbin.org/ip", "https://httpbin.org/ip"] |
| 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"] |
4 | 5 | for url in urls
|
5 | 6 | @test Base.download_url(url) == url
|
6 | 7 | end
|
|
17 | 18 | mktempdir() do temp_dir
|
18 | 19 | # Download a file
|
19 | 20 | file = joinpath(temp_dir, "ip")
|
20 |
| - @test download("http://httpbin.org/ip", file) == file |
| 21 | + @test download("https://httpbin.julialang.org/ip", file) == file |
21 | 22 | @test isfile(file)
|
22 | 23 | @test !isempty(read(file))
|
23 | 24 | ip = read(file, String)
|
24 | 25 |
|
25 | 26 | # Test download rewrite hook
|
26 | 27 | push!(Base.DOWNLOAD_HOOKS, url->replace(url, r"/status/404$" => "/ip"))
|
27 |
| - @test download("http://httpbin.org/status/404", file) == file |
| 28 | + @test download("https://httpbin.julialang.org/status/404", file) == file |
28 | 29 | @test isfile(file)
|
29 | 30 | @test !isempty(read(file))
|
30 | 31 | @test ip == read(file, String)
|
31 | 32 | pop!(Base.DOWNLOAD_HOOKS)
|
32 | 33 |
|
33 | 34 | # Download an empty file
|
34 | 35 | empty_file = joinpath(temp_dir, "empty")
|
35 |
| - @test download("http://httpbin.org/status/200", empty_file) == empty_file |
| 36 | + @test download("https://httpbin.julialang.org/status/200", empty_file) == empty_file |
36 | 37 |
|
37 | 38 | # Windows and older versions of curl do not create the empty file (https://github.com/curl/curl/issues/183)
|
38 | 39 | @test !isfile(empty_file) || isempty(read(empty_file))
|
39 | 40 |
|
40 | 41 | # Make sure that failed downloads do not leave files around
|
41 | 42 | missing_file = joinpath(temp_dir, "missing")
|
42 |
| - @test_throws ProcessFailedException download("http://httpbin.org/status/404", missing_file) |
| 43 | + @test_throws ProcessFailedException download("https://httpbin.julialang.org/status/404", missing_file) |
43 | 44 | @test !isfile(missing_file)
|
44 | 45 |
|
45 |
| - # Make sure we properly handle metachar ' |
46 |
| - metachar_file = joinpath(temp_dir, "metachar") |
47 |
| - download("https://httpbin.org/get?test='^'", metachar_file) |
48 |
| - metachar_string = read(metachar_file, String) |
49 |
| - m = match(r"\"url\"\s*:\s*\"(.*)\"", metachar_string) |
50 |
| - @test m.captures[1] == "https://httpbin.org/get?test='^'" |
| 46 | + # Make sure we properly handle metachar ' on windows with ^ escaping |
| 47 | + if Sys.iswindows() |
| 48 | + metachar_file = joinpath(temp_dir, "metachar") |
| 49 | + Base.download_powershell("https://httpbin.julialang.org/get?test='^'", metachar_file) |
| 50 | + metachar_string = read(metachar_file, String) |
| 51 | + m = match(r"\"test\"\s*:\s*\"(.*)\"", metachar_string) |
| 52 | + @test m.captures[1] == "'^'" |
| 53 | + end |
51 | 54 |
|
52 | 55 | # Use a TEST-NET (192.0.2.0/24) address which shouldn't be bound
|
53 | 56 | invalid_host_file = joinpath(temp_dir, "invalid_host")
|
|
0 commit comments