Skip to content

Commit

Permalink
fix: Preserve data after reading response body stream in S3/200 middl…
Browse files Browse the repository at this point in the history
…eware (#1303)
  • Loading branch information
jbelkins authored Jan 18, 2024
1 parent 77ebe70 commit 014fa3c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public struct AWSS3ErrorWith200StatusXMLMiddleware<OperationStackOutput>: Middle
return response
}

response.httpResponse.body = .data(data)

let xmlString = String(data: data, encoding: .utf8) ?? ""
if xmlString.contains("<Error>") {
// Handle the error as a 500 Internal Server Error
var modifiedResponse = response
let modifiedResponse = response
modifiedResponse.httpResponse.statusCode = .internalServerError
return modifiedResponse
}
Expand Down

0 comments on commit 014fa3c

Please sign in to comment.