From 014fa3cbfd052b74dd43a15446d0ad36e1975b35 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Thu, 18 Jan 2024 13:36:09 -0600 Subject: [PATCH] fix: Preserve data after reading response body stream in S3/200 middleware (#1303) --- .../Middlewares/AWSS3ErrorWith200StatusXMLMiddleware.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Core/AWSClientRuntime/Middlewares/AWSS3ErrorWith200StatusXMLMiddleware.swift b/Sources/Core/AWSClientRuntime/Middlewares/AWSS3ErrorWith200StatusXMLMiddleware.swift index da3c357ed44..2801ef7769a 100644 --- a/Sources/Core/AWSClientRuntime/Middlewares/AWSS3ErrorWith200StatusXMLMiddleware.swift +++ b/Sources/Core/AWSClientRuntime/Middlewares/AWSS3ErrorWith200StatusXMLMiddleware.swift @@ -33,10 +33,12 @@ public struct AWSS3ErrorWith200StatusXMLMiddleware: Middle return response } + response.httpResponse.body = .data(data) + let xmlString = String(data: data, encoding: .utf8) ?? "" if xmlString.contains("") { // Handle the error as a 500 Internal Server Error - var modifiedResponse = response + let modifiedResponse = response modifiedResponse.httpResponse.statusCode = .internalServerError return modifiedResponse }