Skip to content

Commit

Permalink
Always compress responses when the client compression is on (#1286)
Browse files Browse the repository at this point in the history
* Dont decompress a non-200 response

* Compress all responses if compression is enabled
  • Loading branch information
zhkvia authored May 8, 2024
1 parent 6985077 commit c3f7a77
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 1 addition & 4 deletions conn_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,17 +424,14 @@ func (h *httpConnect) readRawResponse(response *http.Response) (body []byte, err
if err != nil {
return nil, err
}
if response.StatusCode == http.StatusForbidden {
return nil, errors.New(string(body))
}
if h.compression == CompressionLZ4 || h.compression == CompressionZSTD {
chReader := chproto.NewReader(reader)
chReader.EnableCompression()
reader = chReader
}

body, err = io.ReadAll(reader)
if err != nil {
if err != nil && !errors.Is(err, io.EOF) {
return nil, err
}
return body, nil
Expand Down
1 change: 1 addition & 0 deletions conn_http_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ func (b *httpBatch) Send() (err error) {
headers["Content-Encoding"] = b.conn.compression.String()
case CompressionZSTD, CompressionLZ4:
options.settings["decompress"] = "1"
options.settings["compress"] = "1"
}

go func() {
Expand Down

0 comments on commit c3f7a77

Please sign in to comment.