Skip to content

Commit

Permalink
use if conditional for gzip
Browse files Browse the repository at this point in the history
  • Loading branch information
darshanime committed Apr 25, 2020
1 parent 8bba184 commit 46f8524
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions print/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ func ResponseToString(resp *http.Response) string {
str.WriteString("\n")

var reader io.ReadCloser
switch resp.Header.Get("Content-Encoding") {
case "gzip":

if contentEncoding := resp.Header.Get("Content-Encoding"); contentEncoding == "gzip" {
gzipReader, err := gzip.NewReader(resp.Body)
if err != nil {
reader = resp.Body
defer gzipReader.Close()
} else {
reader = gzipReader
}
defer gzipReader.Close()
default:
} else {
reader = resp.Body
}
defer resp.Body.Close()
Expand Down

0 comments on commit 46f8524

Please sign in to comment.