Skip to content

Commit

Permalink
Curl: Improve Accept-Encoding comment
Browse files Browse the repository at this point in the history
1d46cec
tried to improve the comment but the new content implies an empty header
will be sent.

That is not the case. Quoting from <https://curl.se/libcurl/c/CURLOPT_HTTPHEADER.html>:

    If you add a header with no content as in 'Accept:'
    (no data on the right side of the colon),
    the internally used header is disabled/removed.

Let’s clarify the point is removing the header to get the default '*'
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding#sect2>:

    *: Matches any content encoding not already listed in the header.
    This is the default value if the header is not present.
    This directive does not suggest that any algorithm is supported
    but indicates that no preference is expressed.

As was probably intended by the original change that introduced this:
1a9ad6b
  • Loading branch information
jtojnar committed Apr 13, 2024
1 parent 429cb67 commit 55cba70
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Handler/CurlFactory.php
Expand Up @@ -390,8 +390,9 @@ private function applyHandlerOptions(EasyHandle $easy, array &$conf): void
// The empty string enables all available decoders and implicitly
// sets a matching 'Accept-Encoding' header.
$conf[\CURLOPT_ENCODING] = '';
// But as the user did not specify any acceptable encodings we need
// to overwrite this implicit header with an empty one.
// But as the user did not specify any encoding preference,
// let’s leave it up to server by preventing curl from sending
// the header, which will be interpreted as 'Accept-Encoding: *'.
$conf[\CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
}
}
Expand Down

0 comments on commit 55cba70

Please sign in to comment.