From 556b530ac66bb7751e44a866fd9f3b1f613a1edb Mon Sep 17 00:00:00 2001 From: Nero Blackstone Date: Thu, 27 Jul 2023 23:51:22 +0800 Subject: [PATCH 1/2] fix incorrect response header content-type reading --- .gitignore | 2 ++ Project.toml | 2 +- src/client.jl | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ba67bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Manifest.toml +.vscode \ No newline at end of file diff --git a/Project.toml b/Project.toml index 0702f3b..737a10e 100644 --- a/Project.toml +++ b/Project.toml @@ -24,7 +24,7 @@ JSON = "0.20, 0.21" LibCURL = "0.6" MbedTLS = "0.6.8, 0.7, 1" TimeZones = "1" -URIs = "1.3" +URIs = "1.4" julia = "1.6" [extras] diff --git a/src/client.jl b/src/client.jl index 305dfd4..11ca47d 100644 --- a/src/client.jl +++ b/src/client.jl @@ -321,7 +321,7 @@ response(::Type{Nothing}, resp::Downloads.Response, body) = nothing::Nothing response(::Type{T}, resp::Downloads.Response, body) where {T <: Real} = response(T, body)::T response(::Type{T}, resp::Downloads.Response, body) where {T <: String} = response(T, body)::T function response(::Type{T}, resp::Downloads.Response, body) where {T} - ctype = header(resp, "Content-Type", "application/json") + ctype = header(resp, "content-type", "application/json") response(T, is_json_mime(ctype), body)::T end response(::Type{T}, ::Nothing, body) where {T} = response(T, true, body) From 2dbfbd9e645cdf321f657f82e370c51f42dc9c17 Mon Sep 17 00:00:00 2001 From: Nero Blackstone Date: Fri, 28 Jul 2023 10:33:30 +0800 Subject: [PATCH 2/2] case insensitive --- Project.toml | 2 +- src/client.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 737a10e..0702f3b 100644 --- a/Project.toml +++ b/Project.toml @@ -24,7 +24,7 @@ JSON = "0.20, 0.21" LibCURL = "0.6" MbedTLS = "0.6.8, 0.7, 1" TimeZones = "1" -URIs = "1.4" +URIs = "1.3" julia = "1.6" [extras] diff --git a/src/client.jl b/src/client.jl index 11ca47d..6624c08 100644 --- a/src/client.jl +++ b/src/client.jl @@ -312,7 +312,7 @@ end function header(resp::Downloads.Response, name::AbstractString, defaultval::AbstractString) for (n,v) in resp.headers - (n == name) && (return v) + (lowercase(n) == lowercase(name)) && (return v) end return defaultval end @@ -321,7 +321,7 @@ response(::Type{Nothing}, resp::Downloads.Response, body) = nothing::Nothing response(::Type{T}, resp::Downloads.Response, body) where {T <: Real} = response(T, body)::T response(::Type{T}, resp::Downloads.Response, body) where {T <: String} = response(T, body)::T function response(::Type{T}, resp::Downloads.Response, body) where {T} - ctype = header(resp, "content-type", "application/json") + ctype = header(resp, "Content-Type", "application/json") response(T, is_json_mime(ctype), body)::T end response(::Type{T}, ::Nothing, body) where {T} = response(T, true, body)