Bug #75315 [Com]: curl cutting off post data
| From: | j dot wessel at nolis dot de | Date: | Thu, 05 Oct 2017 12:37:54 +0000 |
| Subject: | Bug #75315 [Com]: curl cutting off post data | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-211534@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75315&edit=1
ID: 75315
Comment by: j dot wessel at nolis dot de
Reported by: j dot wessel at nolis dot de
Summary: curl cutting off post data
Status: Open
Type: Bug
Package: cURL related
Operating System: Debian 9
PHP Version: 7.1.10
Block user comment: N
Private report: N
New Comment:
We create a ticket at the curl project: https://github.com/curl/curl/issues/1949
Previous Comments:
------------------------------------------------------------------------
[2017-10-05 12:22:00] j dot wessel at nolis dot de
Description:
------------
Tested with: PHP 7.1.10, PHP 5.6.31 and curl 7.56.0
The script works with curl 7.55.0 correctly.
Test script:
---------------
curl.php
--------------------------------------------------------------------------------------
<?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 this bug report at https://bugs.php.net/bug.php?id=75315&edit=1