Skip to content

Fix GH-11433: Unable to set CURLOPT_ACCEPT_ENCODING to NULL #11446

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -2493,7 +2493,6 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
case CURLOPT_TLSAUTH_TYPE:
case CURLOPT_TLSAUTH_PASSWORD:
case CURLOPT_TLSAUTH_USERNAME:
case CURLOPT_ACCEPT_ENCODING:
case CURLOPT_TRANSFER_ENCODING:
case CURLOPT_DNS_SERVERS:
case CURLOPT_MAIL_AUTH:
Expand Down Expand Up @@ -2553,6 +2552,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
case CURLOPT_RANGE:
case CURLOPT_FTP_ACCOUNT:
case CURLOPT_RTSP_SESSION_ID:
case CURLOPT_ACCEPT_ENCODING:
#if LIBCURL_VERSION_NUM >= 0x072100 /* Available since 7.33.0 */
case CURLOPT_DNS_INTERFACE:
case CURLOPT_DNS_LOCAL_IP4:
Expand Down
38 changes: 38 additions & 0 deletions ext/curl/tests/curl_setopt_CURLOPT_ACCEPT_ENCODING.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--TEST--
Test curl_setopt() with CURLOPT_ACCEPT_ENCODING
--EXTENSIONS--
curl
--FILE--
<?php

include 'server.inc';
$host = curl_cli_server_start();

$ch = curl_init();

$url = "{$host}/get.inc?test=";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_ACCEPT_ENCODING, "gzip");
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);

// First execution, with gzip accept
curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);

// Second execution, with the encoding accept disabled
curl_setopt($ch, CURLOPT_ACCEPT_ENCODING, NULL);
curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);

curl_close($ch);
?>
--EXPECTF--
GET /get.inc?test= HTTP/1.1
Host: %s
Accept: */*
Accept-Encoding: gzip

GET /get.inc?test= HTTP/1.1
Host: %s
Accept: */*