From 7feaa07280dc37bac07a3f91a3c0e8264b14d875 Mon Sep 17 00:00:00 2001 From: Jack Dunn Date: Wed, 29 Jun 2022 09:44:04 -0400 Subject: [PATCH 1/2] Fix error type for HTTP 1.0 Fixes #558 --- src/AWSCredentials.jl | 2 +- test/patch.jl | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/AWSCredentials.jl b/src/AWSCredentials.jl index 01b0ba366e..687abeed9a 100644 --- a/src/AWSCredentials.jl +++ b/src/AWSCredentials.jl @@ -216,7 +216,7 @@ function ec2_instance_metadata(path::AbstractString) request = try @mock HTTP.request("GET", uri; connect_timeout=1) catch e - if e isa HTTP.ConnectionPool.ConnectTimeout + if e isa HTTP.ConnectError nothing else rethrow() diff --git a/test/patch.jl b/test/patch.jl index bdf61f127d..dfbd43b29e 100644 --- a/test/patch.jl +++ b/test/patch.jl @@ -129,7 +129,10 @@ end _instance_metadata_timeout_patch = @patch function HTTP.request( method::String, url; kwargs... ) - return throw(HTTP.ConnectionPool.ConnectTimeout("169.254.169.254", "80")) + return throw(HTTP.ConnectError( + "http://169.254.169.254/latest/meta-data/iam/info", + HTTP.ConnectionPool.ConnectTimeout("169.254.169.254", "80"), + )) end # This patch causes `HTTP.request` to return all of its keyword arguments From fbb078252523ced8085ae76a8abfffd43ba06c99 Mon Sep 17 00:00:00 2001 From: Jack Dunn Date: Wed, 29 Jun 2022 14:37:15 -0400 Subject: [PATCH 2/2] Fix formatting --- test/patch.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/patch.jl b/test/patch.jl index dfbd43b29e..9aab638ce3 100644 --- a/test/patch.jl +++ b/test/patch.jl @@ -129,10 +129,12 @@ end _instance_metadata_timeout_patch = @patch function HTTP.request( method::String, url; kwargs... ) - return throw(HTTP.ConnectError( - "http://169.254.169.254/latest/meta-data/iam/info", - HTTP.ConnectionPool.ConnectTimeout("169.254.169.254", "80"), - )) + return throw( + HTTP.ConnectError( + "http://169.254.169.254/latest/meta-data/iam/info", + HTTP.ConnectionPool.ConnectTimeout("169.254.169.254", "80"), + ), + ) end # This patch causes `HTTP.request` to return all of its keyword arguments