Skip to content

Commit

Permalink
Try #560:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] committed Jun 20, 2022
2 parents 517a05e + a0672d0 commit 6088e80
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ XMLDict = "228000da-037f-5747-90a9-8195ccbf91a5"
[compat]
Compat = "3.29"
GitHub = "5"
HTTP = "0.9.17"
HTTP = "0.9.17, 1.0"
IniFile = "0.5"
JSON = "0.18, 0.19, 0.20, 0.21"
MbedTLS = "0.6, 0.7, 1"
Expand Down
3 changes: 1 addition & 2 deletions src/AWSExceptions.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module AWSExceptions

using HTTP
using HTTP.MessageRequest: body_was_streamed
using JSON
using XMLDict
using XMLDict: XMLDictElement
Expand Down Expand Up @@ -114,7 +113,7 @@ function AWSException(e::HTTP.StatusError, body::AbstractString)
message = get(info, "Message", message)
message = get(info, "message", message)

streamed_body = e.response.body == body_was_streamed ? body : nothing
streamed_body = e.response.body isa IO ? body : nothing

return AWSException(code, message, info, e, streamed_body)
end
Expand Down
6 changes: 1 addition & 5 deletions src/utilities/downloads_backend.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using HTTP.MessageRequest: body_was_streamed

"""
DownloadsBackend <: AWS.AbstractBackend
Expand Down Expand Up @@ -125,9 +123,7 @@ function _http_request(backend::DownloadsBackend, request::Request, response_str
end

function _http_response(req::Request, res::Downloads.Response; throw::Bool=true)
response = HTTP.Response(
res.status, res.headers; body=body_was_streamed, request=nothing
)
response = HTTP.Response(res.status, res.headers; body=UInt8[], request=nothing)

if throw && HTTP.iserror(response)
target = HTTP.resource(HTTP.URI(req.url))
Expand Down
12 changes: 4 additions & 8 deletions src/utilities/request.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,6 @@ end
function _http_request(http_backend::HTTPBackend, request::Request, response_stream::IO)
http_options = merge(http_backend.http_options, request.http_options)

# HTTP options such as `status_exception` need to be used when creating the stack
http_stack = HTTP.stack(;
redirect=false, retry=false, aws_authorization=false, http_options...
)

local buffer
local response

Expand All @@ -219,13 +214,14 @@ function _http_request(http_backend::HTTPBackend, request::Request, response_str
buffer = Base.BufferStream()

response = @mock HTTP.request(
http_stack,
request.request_method,
HTTP.URI(request.url),
HTTP.mkheaders(request.headers),
request.content;
require_ssl_verification=false,
redirect=false,
retry=false,
response_stream=buffer,
aws_authorization=false,
http_options...,
)

Expand All @@ -240,7 +236,7 @@ function _http_request(http_backend::HTTPBackend, request::Request, response_str
# https://github.com/JuliaWeb/HTTP.jl/issues/382
return isa(e, Sockets.DNSError) ||
isa(e, HTTP.ParseError) ||
isa(e, HTTP.IOError) ||
(isdefined(HTTP, :IOError) && isa(e, HTTP.IOError)) ||
isa(e, Base.IOError) ||
(isa(e, HTTP.StatusError) && _http_status(e) >= 500)
end
Expand Down

0 comments on commit 6088e80

Please sign in to comment.