Skip to content

Commit

Permalink
Merge #557
Browse files Browse the repository at this point in the history
557: Consume buffer when creating AWSException r=iamed2 a=quinnj

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.

Co-authored-by: Jacob Quinn <[email protected]>
  • Loading branch information
bors[bot] and quinnj authored Jun 16, 2022
2 parents d52c639 + 9585f51 commit e0b07f9
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 e0b07f9

Please sign in to comment.