Skip to content

Commit cfb0fd4

Browse files
RachelTuckerrpmoore
authored andcommitted
GOSDK-29: SDK leaks memory from unclosed HTTP response bodies. Closing all http response body's within the response structs to enusre it gets closed in error cases and when there is no request payload cases. (#94)
1 parent 61b0536 commit cfb0fd4

File tree

3 files changed

+378
-11
lines changed

3 files changed

+378
-11
lines changed

ds3/models/responseHandlingUtil.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ type modelParser interface {
2626
func parseResponsePayload(webResponse WebResponse, parsedBody modelParser) error {
2727
// Clean up the response body.
2828
body := webResponse.Body()
29-
defer body.Close()
3029

3130
// Create the xml tree
3231
root, err := parseXmlTree(body)
@@ -56,7 +55,6 @@ func parseXmlTree(reader io.ReadCloser) (*XmlNode, error) {
5655
func getResponseBodyAsString(webResponse WebResponse) (string, error) {
5756
// Clean up the response body.
5857
body := webResponse.Body()
59-
defer body.Close()
6058

6159
// Get the bytes or forward the error
6260
bytes, err := ioutil.ReadAll(body)

0 commit comments

Comments
 (0)