Skip to content

Commit

Permalink
Compress all responses if compression is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
zhkvia committed May 2, 2024
1 parent 18c54b0 commit a1b3d5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions conn_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ func (h *httpConnect) readRawResponse(response *http.Response) (body []byte, err
if err != nil {
return nil, err
}
if response.StatusCode == http.StatusOK && (h.compression == CompressionLZ4 || h.compression == CompressionZSTD) {
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 a1b3d5d

Please sign in to comment.