forked from ContentSquare/chproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix the bytes encode/decode for redis cache (ContentSquare#153)
* fix: fix the bytes encode/decode for redis cache Using `string(data)` to convert the byte array to string introduces error in json marshal/unmarshal, hence causes error when returning cached response from redis. The reason is `Unmarshal` function in `encode/json` would replace invalid UTF-8 or invalid UTF-16 pairs with `U+FFFD`, therefore the `payload` string in `redisCachePayload` will actually change after json marshal/unmarshal since the byte array may contain invalid UTF-8/UTF-16 byte, the length of payload will thereby change, resulting the http server to find the declared length in header `Content-Length` mismatches the actual length of payload. The fix is to base64-encode/decode the byte array to string, thereby eliminates invalid UTF-8/UTF-16 bytes. * fix: add test case about encode/decode the cached value add test cases for base64 encode/decode the cached value * fix: adjust the waiting time of `queue_overflow_for_user` case to pass ci minimize the waiting time between two consecutive requests
- Loading branch information
1 parent
5b23001
commit 6cfac12
Showing
4 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
/docs/.output | ||
/docs/.nuxt | ||
/docs/static/sw.js | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters