Skip to content

Commit

Permalink
Consume buffer when creating AWSException
Browse files Browse the repository at this point in the history
At least partially fixes #537. While investigating the depths of how AWS.jl
and HTTP.jl interact, and working on several PRs to improve HTTP.jl, I
noticed a pretty simple way to fix #537 in the most common case where
the user doesn't pass in their own response_stream. Because the default
response_stream is an `IOBuffer`, we can "consume" it's contents when
an AWSException is thrown and thus when the request is retried, the buffer
will be "clean" in that the exception response body has been extracted.
  • Loading branch information
quinnj committed Jun 15, 2022
1 parent d52c639 commit 9585f51
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/AWSExceptions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function Base.show(io::IO, e::AWSException)
end

AWSException(e::HTTP.StatusError) = AWSException(e, String(copy(e.response.body)))
AWSException(e::HTTP.StatusError, io::IOBuffer) = AWSException(e, String(take!(io)))

function AWSException(e::HTTP.StatusError, stream::IO)
seekstart(stream)
Expand Down

0 comments on commit 9585f51

Please sign in to comment.