always send an "Accept-Encoding" header with HTTP requests #17009
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes a fun issue reported in https://forum.matomo.org/t/error-array-offset-on-bool-in-securityinfo-matomo-4-1-0/39986
I originally blamed
safe_unserialize
to be broken, but it turned out that even aHttp::sendHttpRequest('https://php.net/releases/?json=1&version=7', $timeout);
was only returning garbled output.It turns out that whatever server the PHP team uses, assumes that when you use Firefox, you are always able to uncompress gzip-encoded content, even if it was not requested. (and Matomo forwards the User Agent of the user for its HTTP requests).
So PHP curl recieved a gziped response even though it didn't request it and therefore didn't automatically unpack it. Adding
CURLOPT_ENCODING => ""
tells curl to always request all encodings it supports and therefore be able to handle any gzipped response.Review