From 9585f51c68ebac9c133dcff3e73d189ab4584f48 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Wed, 15 Jun 2022 15:52:47 -0600 Subject: [PATCH] Consume buffer when creating AWSException 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. --- src/AWSExceptions.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/AWSExceptions.jl b/src/AWSExceptions.jl index a48fe39c73..76ee1b201f 100644 --- a/src/AWSExceptions.jl +++ b/src/AWSExceptions.jl @@ -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)