xref: /PHP-8.0/ext/curl/tests/bug80595.phpt (revision 38ad37ad)
1--TEST--
2Bug #80595 (Resetting POSTFIELDS to empty array breaks request)
3--SKIPIF--
4<?php include 'skipif.inc'; ?>
5--FILE--
6<?php
7include 'server.inc';
8$host = curl_cli_server_start();
9$ch = curl_init();
10curl_setopt_array($ch, [
11    CURLOPT_RETURNTRANSFER => true,
12    CURLOPT_POST           => true,
13    CURLOPT_URL            => "{$host}/get.inc?test=post",
14]);
15
16curl_setopt($ch, CURLOPT_POSTFIELDS, ['foo' => 'bar']);
17var_dump(curl_exec($ch));
18
19curl_setopt($ch, CURLOPT_POSTFIELDS, []);
20var_dump(curl_exec($ch));
21?>
22--EXPECT--
23string(43) "array(1) {
24  ["foo"]=>
25  string(3) "bar"
26}
27"
28string(13) "array(0) {
29}
30"
31