Skip to content

Commit 0bcffa6

Browse files
committed
Merged pull request #8460
2 parents 2768597 + f7a5353 commit 0bcffa6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

ext/curl/interface.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,15 +2061,17 @@ static void free_cb(void *arg) /* {{{ */
20612061
/* }}} */
20622062
#endif
20632063

2064+
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
20642065
static inline CURLcode add_simple_field(curl_mime *mime, zend_string *string_key, zval *current)
2066+
#else
2067+
static inline CURLcode add_simple_field(struct HttpPost **first, struct HttpPost **last, zend_string *string_key, zval *current)
2068+
#endif
20652069
{
20662070
CURLcode error = CURLE_OK;
20672071
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
20682072
curl_mimepart *part;
20692073
CURLcode form_error;
20702074
#else
2071-
struct HttpPost *first = NULL;
2072-
struct HttpPost *last = NULL;
20732075
CURLFORMcode form_error;
20742076
#endif
20752077
zend_string *postval, *tmp_postval;
@@ -2091,7 +2093,7 @@ static inline CURLcode add_simple_field(curl_mime *mime, zend_string *string_key
20912093
/* The arguments after _NAMELENGTH and _CONTENTSLENGTH
20922094
* must be explicitly cast to long in curl_formadd
20932095
* use since curl needs a long not an int. */
2094-
form_error = curl_formadd(&first, &last,
2096+
form_error = curl_formadd(first, last,
20952097
CURLFORM_COPYNAME, ZSTR_VAL(string_key),
20962098
CURLFORM_NAMELENGTH, ZSTR_LEN(string_key),
20972099
CURLFORM_COPYCONTENTS, ZSTR_VAL(postval),
@@ -2303,14 +2305,22 @@ static inline zend_result build_mime_structure_from_hash(php_curl *ch, zval *zpo
23032305
zval *current_element;
23042306

23052307
ZEND_HASH_FOREACH_VAL(HASH_OF(current), current_element) {
2308+
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
23062309
add_simple_field(mime, string_key, current_element);
2310+
#else
2311+
add_simple_field(&first, &last, string_key, current_element);
2312+
#endif
23072313
} ZEND_HASH_FOREACH_END();
23082314

23092315
zend_string_release_ex(string_key, 0);
23102316
continue;
23112317
}
23122318

2319+
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
23132320
add_simple_field(mime, string_key, current);
2321+
#else
2322+
add_simple_field(&first, &last, string_key, current);
2323+
#endif
23142324

23152325
zend_string_release_ex(string_key, 0);
23162326
} ZEND_HASH_FOREACH_END();

ext/curl/tests/curl_postfields_array.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ $options = [
3131
CURLOPT_FORBID_REUSE => 1,
3232
CURLOPT_TIMEOUT => 1,
3333
CURLOPT_POSTFIELDS => $fields,
34+
CURLOPT_HTTPHEADER => [ 'Expect:' ],
3435
];
3536

3637
$ch = curl_init();

0 commit comments

Comments
 (0)