Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using gzip compression breaks api calls after a lot of calls. #742

Closed
Mebby8448 opened this issue Oct 23, 2023 · 1 comment · Fixed by #755
Closed

Using gzip compression breaks api calls after a lot of calls. #742

Mebby8448 opened this issue Oct 23, 2023 · 1 comment · Fixed by #755

Comments

@Mebby8448
Copy link

Mebby8448 commented Oct 23, 2023

  • Algolia Client Version: 3.31.0
  • Language Version: Golang 1.21.0

Description

Using gzip compression in the client leads to accumulating the addition of the same header content-encoding: gzip to each api call.
As a result of this after a lot of calls, you will get 494 errors from Algolia API on each call.

Output from Algolia search API Logs:
Host: xxxxxxxxxxx.algolia.net
User-Agent: Algolia for Go (3.31.0);Go (go1.21.1)
Transfer-Encoding: chunked
Connection: Keep-Alive
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: gzip
Content-Encoding: ...

Steps To Reproduce

  1. Add gzip encoding in the client
  2. Call API N times
  3. Check the header to the Aloglia API, after 2-3 calls. The headers accumulate
Fluf22 added a commit that referenced this issue Mar 4, 2024
#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
@Fluf22
Copy link
Contributor

Fluf22 commented Mar 4, 2024

Thank you very much!
Sorry for the delay ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants