Skip to content

Commit

Permalink
Improve inferability of download() (JuliaLang#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobnissen authored Aug 6, 2021
1 parent adbb974 commit 848d374
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/Curl/Easy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,13 @@ function get_response_info(easy::Easy)
for hdr in easy.res_hdrs
if contains(hdr, r"^\s*$")
# ignore
elseif (m = match(r"^(HTTP/\d+(?:.\d+)?\s+\d+\b.*?)\s*$", hdr)) !== nothing
message = m.captures[1]
elseif (m = match(r"^(HTTP/\d+(?:.\d+)?\s+\d+\b.*?)\s*$", hdr); m) !== nothing
message = m.captures[1]::SubString{String}
empty!(headers)
elseif (m = match(r"^(\S[^:]*?)\s*:\s*(.*?)\s*$", hdr)) !== nothing
push!(headers, lowercase(m.captures[1]) => m.captures[2])
elseif (m = match(r"^(\S[^:]*?)\s*:\s*(.*?)\s*$", hdr); m) !== nothing
key = lowercase(m.captures[1]::SubString{String})
val = m.captures[2]::SubString{String}
push!(headers, key => val)
else
@warn "malformed HTTP header" url status header=hdr
end
Expand Down
2 changes: 1 addition & 1 deletion src/Curl/Multi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
function remove_handle(multi::Multi, easy::Easy)
lock(multi.lock) do
@check curl_multi_remove_handle(multi.handle, easy.handle)
deleteat!(multi.easies, findlast(==(easy), multi.easies))
deleteat!(multi.easies, findlast(==(easy), multi.easies)::Int)
!isempty(multi.easies) && return
cleanup_cb = @cfunction(cleanup_callback, Cvoid, (Ptr{Cvoid},))
if multi.grace <= 0
Expand Down
2 changes: 1 addition & 1 deletion src/Downloads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function download(
progress = progress,
verbose = verbose,
downloader = downloader,
)
)::Response
status_ok(response.proto, response.status) && return output
throw(RequestError(url, Curl.CURLE_OK, "", response))
end
Expand Down

0 comments on commit 848d374

Please sign in to comment.