Skip to content

Commit 86675dd

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79033: Curl timeout error with specific url and post
2 parents 184f118 + 6d1dff6 commit 86675dd

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

ext/curl/interface.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,7 +2605,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
26052605
zend_string *string_key;
26062606
zend_ulong num_key;
26072607
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
2608-
curl_mime *mime;
2608+
curl_mime *mime = NULL;
26092609
curl_mimepart *part;
26102610
CURLcode form_error;
26112611
#else
@@ -2620,9 +2620,11 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
26202620
}
26212621

26222622
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
2623-
mime = curl_mime_init(ch->cp);
2624-
if (mime == NULL) {
2625-
return FAILURE;
2623+
if (zend_hash_num_elements(postfields) > 0) {
2624+
mime = curl_mime_init(ch->cp);
2625+
if (mime == NULL) {
2626+
return FAILURE;
2627+
}
26262628
}
26272629
#endif
26282630

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)