Bug #75764 [NEW]: cUrl post large data goes wrong
| From: | peter at grootplezier dot nl | Date: | Fri, 05 Jan 2018 10:16:06 +0000 |
| Subject: | Bug #75764 [NEW]: cUrl post large data goes wrong | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213384@lists.php.net to get a copy of this message | ||
From: peter at grootplezier dot nl
Operating system: Windows
PHP version: 7.2.1
Package: cURL related
Bug Type: Bug
Bug description:cUrl post large data goes wrong
Description:
------------
Tested with: PHP 7.1.10 and curl 7.56.0
The script works with curl 7.54.0 correctly.
Works in the newest curl version. But this is still not implemented in
the Windows version of PHP.
Test script:
---------------
<?php
//generate string data
function getStr($num) {
$bstring = 'abcdefghijklmnopqrstuvxyz0123456789';
$str = '';
for($i = 0; $i < $num; $i++) {
$str .= $bstring;
}
return $str;
}
$json = [
'json1' => getStr(200),
'json2' => getStr(200),
'json3' => getStr(200),
'json4' => getStr(200),
];
$post = [
'test1' => 'a',
'test2' => 'b',
'test3' => 'c',
'test4' => json_encode($json) //or use print_r or var_dump with return
parameter
];
$ch = curl_init();
//send encoded json-data to service
curl_setopt($ch, CURLOPT_URL, 'https://localhost/service.php');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec ($ch);
curl_close($ch);
var_dump($result);
?>
service.php
--------------------------------------------------------------------------------------
<?php
//get the post data and write into request.log
$result = file_put_contents('request.log', print_r($_REQUEST, true));
var_dump($result);
//the content of $_REQUEST is wrong, json1 is repeated, content is
cutted off
//expected result: correct content in $_REQUEST
?>
Expected result:
----------------
Correct post data in $_REQUEST.
Actual result:
--------------
the content of $_REQUEST is wrong, json1 is repeated, content is cutted
off, the post data is corrupt
--
Edit bug report at https://bugs.php.net/bug.php?id=75764&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75764&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75764&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75764&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75764&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75764&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75764&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75764&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75764&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75764&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75764&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75764&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75764&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75764&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75764&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75764&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75764&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75764&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75764&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75764&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75764&r=mysqlcfg