File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -333,7 +333,7 @@ function request(
333
333
end
334
334
end
335
335
else
336
- set_body (easy, have_output)
336
+ set_body (easy, have_output && method != " HEAD " )
337
337
end
338
338
method != = nothing && set_method (easy, method)
339
339
progress != = nothing && enable_progress (easy)
Original file line number Diff line number Diff line change @@ -61,6 +61,24 @@ include("setup.jl")
61
61
@test resp. status == 200
62
62
end
63
63
64
+ # https://github.com/JuliaLang/Downloads.jl/issues/131
65
+ @testset " head request" begin
66
+ url = server * " /image/jpeg"
67
+ output = IOBuffer ()
68
+ resp = request (url; method= " HEAD" , output= output)
69
+ @test resp isa Response
70
+ @test resp. proto == " https"
71
+ @test resp. status == 200
72
+ @test isempty (take! (output)) # no output from a `HEAD`
73
+ len = parse (Int, Dict (resp. headers)[" content-length" ])
74
+
75
+ # when we make a `GET` instead of a `HEAD`, we get a body with the content-length
76
+ # returned from the `HEAD` request.
77
+ resp = request (url; method= " GET" , output= output)
78
+ bytes = take! (output)
79
+ @test length (bytes) == len
80
+ end
81
+
64
82
@testset " put request" begin
65
83
url = " $server /put"
66
84
data = " Hello, world!"
You can’t perform that action at this time.
0 commit comments