Skip to content

Commit

Permalink
fix(transport): set header when compression is enabled instead of add… (
Browse files Browse the repository at this point in the history
#755)

…ing a new one

| Q                 | A
| ----------------- | ----------
| Bug fix?          | yes
| New feature?      | no
| BC breaks?        | no     
| Related Issue     | Fix #742 [CR-5655]
| Need Doc update   | no


## Describe your change

Replace the `.Add()` method on the headers variable by the `.Set()`
method to avoid piling up the same header.

## What problem is this fixing?

As stated by some user, the current transporter in Go adds a header each
time a request is sent with compression enabled.
Using the `.Set()` method instead fixes the issue.


[CR-5655]:
https://algolia.atlassian.net/browse/CR-5655?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
Fluf22 authored Mar 4, 2024
1 parent 835301c commit a07f0bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion algolia/transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func buildRequest(
if isCompressionEnabled {
switch c {
case compression.GZIP:
req.Header.Add("Content-Encoding", "gzip")
req.Header.Set("Content-Encoding", "gzip")
default:
// Do nothing
}
Expand Down

0 comments on commit a07f0bf

Please sign in to comment.