Skip to content

Commit

Permalink
Refactor maybeDeflate()
Browse files Browse the repository at this point in the history
  • Loading branch information
russellhaering committed May 8, 2018
1 parent 1f48417 commit 92a8582
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions decode_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,16 @@ func DecodeUnverifiedBaseResponse(encodedResponse string) (*types.UnverifiedBase
// the decoder over the deflated data.
func maybeDeflate(data []byte, decoder func([]byte) error) error {
err := decoder(data)
if err != nil {
deflated, err := ioutil.ReadAll(flate.NewReader(bytes.NewReader(data)))
if err != nil {
return err
}
if err == nil {
return nil
}

return decoder(deflated)
deflated, err := ioutil.ReadAll(flate.NewReader(bytes.NewReader(data)))
if err != nil {
return err
}

return nil
return decoder(deflated)
}

// parseResponse is a helper function that was refactored out so that the XML parsing behavior can be isolated and unit tested
Expand Down

0 comments on commit 92a8582

Please sign in to comment.