Skip to content

Commit 6d1dff6

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #79033: Curl timeout error with specific url and post
2 parents 32cd373 + c47b18a commit 6d1dff6

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PHP NEWS
1717
. Fixed bug #79008 (General performance regression with PHP 7.4 on Windows).
1818
(cmb)
1919

20+
- CURL:
21+
. Fixed bug #79033 (Curl timeout error with specific url and post). (cmb)
22+
2023
- Fileinfo:
2124
. Fixed bug #74170 (locale information change after mime_content_type).
2225
(Sergei Turchanov)

ext/curl/interface.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
27542754
zend_string *string_key;
27552755
zend_ulong num_key;
27562756
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
2757-
curl_mime *mime;
2757+
curl_mime *mime = NULL;
27582758
curl_mimepart *part;
27592759
CURLcode form_error;
27602760
#else
@@ -2769,9 +2769,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
27692769
}
27702770

27712771
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
2772-
mime = curl_mime_init(ch->cp);
2773-
if (mime == NULL) {
2774-
return FAILURE;
2772+
if (zend_hash_num_elements(postfields) > 0) {
2773+
mime = curl_mime_init(ch->cp);
2774+
if (mime == NULL) {
2775+
return FAILURE;
2776+
}
27752777
}
27762778
#endif
27772779

ext/curl/tests/bug79033.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #79033 (Curl timeout error with specific url and post)
3+
--SKIPIF--
4+
<?php include 'skipif.inc'; ?>
5+
--FILE--
6+
<?php
7+
include 'server.inc';
8+
$host = curl_cli_server_start();
9+
$ch = curl_init();
10+
curl_setopt_array($ch, [
11+
CURLOPT_URL => "{$host}/get.inc?test=post",
12+
CURLOPT_POST => true,
13+
CURLOPT_POSTFIELDS => [],
14+
CURLINFO_HEADER_OUT => true,
15+
CURLOPT_RETURNTRANSFER => true,
16+
]);
17+
var_dump(curl_exec($ch));
18+
var_dump(curl_getinfo($ch)["request_header"]);
19+
?>
20+
--EXPECTF--
21+
string(%d) "array(0) {
22+
}
23+
"
24+
string(90) "POST /get.inc?test=post HTTP/1.1
25+
Host: localhost:%d
26+
Accept: */*
27+
Content-Length: 0
28+
29+
"

0 commit comments

Comments
 (0)