Skip to content

Commit a8a3b99

Browse files
committed
Fix phpGH-11433: Unable to set CURLOPT_ACCEPT_ENCODING to NULL
Closes phpGH-11446.
1 parent 10d94ac commit a8a3b99

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ PHP NEWS
99
- Core:
1010
. Fixed build for the riscv64 architecture/GCC 12. (Daniil Gentili)
1111

12+
- Curl:
13+
. Fixed bug GH-11433 (Unable to set CURLOPT_ACCEPT_ENCODING to NULL).
14+
(nielsdos)
15+
1216
- DOM:
1317
. Fixed bugs GH-11288 and GH-11289 and GH-11290 and GH-9142 (DOMExceptions
1418
and segfaults with replaceWith). (nielsdos)

ext/curl/interface.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2493,7 +2493,6 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
24932493
case CURLOPT_TLSAUTH_TYPE:
24942494
case CURLOPT_TLSAUTH_PASSWORD:
24952495
case CURLOPT_TLSAUTH_USERNAME:
2496-
case CURLOPT_ACCEPT_ENCODING:
24972496
case CURLOPT_TRANSFER_ENCODING:
24982497
case CURLOPT_DNS_SERVERS:
24992498
case CURLOPT_MAIL_AUTH:
@@ -2553,6 +2552,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
25532552
case CURLOPT_RANGE:
25542553
case CURLOPT_FTP_ACCOUNT:
25552554
case CURLOPT_RTSP_SESSION_ID:
2555+
case CURLOPT_ACCEPT_ENCODING:
25562556
#if LIBCURL_VERSION_NUM >= 0x072100 /* Available since 7.33.0 */
25572557
case CURLOPT_DNS_INTERFACE:
25582558
case CURLOPT_DNS_LOCAL_IP4:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Test curl_setopt() with CURLOPT_ACCEPT_ENCODING
3+
--EXTENSIONS--
4+
curl
5+
--FILE--
6+
<?php
7+
8+
include 'server.inc';
9+
$host = curl_cli_server_start();
10+
11+
$ch = curl_init();
12+
13+
$url = "{$host}/get.inc?test=";
14+
curl_setopt($ch, CURLOPT_URL, $url);
15+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
16+
curl_setopt($ch, CURLOPT_ACCEPT_ENCODING, "gzip");
17+
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
18+
19+
// First execution, with gzip accept
20+
curl_exec($ch);
21+
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
22+
23+
// Second execution, with the encoding accept disabled
24+
curl_setopt($ch, CURLOPT_ACCEPT_ENCODING, NULL);
25+
curl_exec($ch);
26+
echo curl_getinfo($ch, CURLINFO_HEADER_OUT);
27+
28+
curl_close($ch);
29+
?>
30+
--EXPECTF--
31+
GET /get.inc?test= HTTP/1.1
32+
Host: %s
33+
Accept: */*
34+
Accept-Encoding: gzip
35+
36+
GET /get.inc?test= HTTP/1.1
37+
Host: %s
38+
Accept: */*

0 commit comments

Comments
 (0)