Bug #76444 [NEW]: can't read stream from multipart requests
| From: | clark at electrobeat dot dk | Date: | Mon, 11 Jun 2018 08:24:01 +0000 |
| Subject: | Bug #76444 [NEW]: can't read stream from multipart requests | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-215596@lists.php.net to get a copy of this message | ||
From: clark at electrobeat dot dk
Operating system: debian stretch
PHP version: 7.0.30
Package: Streams related
Bug Type: Bug
Bug description:can't read stream from multipart requests
Description:
------------
It's not possible to read the request stream from multipart/form-data
requets
$body = file_get_contents('php://input');
It seems like it has been a open bug for many years so I don't get why
it has never been fixed!?
If a user uploads a file you can't even check if the data part is
gzipped or anything..
It doesn't make sense that you only can read streams from some request
streams but not from others!?
Test script:
---------------
$boundary = 'jlasdifj439';
$field1 = json_encode(['test' => 123]);
$body = '--'.$boundary."\r\n"
.'Content-Disposition: form-data; name="json";
filename="file.pdf"'."\r\n"
.'Content-Type: application/json'."\r\n"
.'Content-Length: '.strlen($field1)."\r\n\r\n"
.$field1."\r\n"
.'--'.$boundary.'--';
$socket = curl_init();
curl_setopt_array($socket, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_VERBOSE => true,
CURLOPT_ENCODING => '',
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0,
]);
curl_setopt($socket, CURLOPT_URL, 'https://api-scan.dynaccount.com/');
curl_setopt($socket, CURLOPT_HTTPHEADER, [
'Content-Type: multipart/form-data; boundary='.$boundary,
]);
curl_setopt($socket, CURLOPT_POSTFIELDS, $body);
if(!$response = curl_exec($socket)){
echo "ERROR!";
}
echo $response;
--
Edit bug report at https://bugs.php.net/bug.php?id=76444&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76444&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76444&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76444&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76444&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76444&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76444&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76444&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76444&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76444&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76444&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76444&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76444&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76444&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76444&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76444&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76444&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76444&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76444&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76444&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76444&r=mysqlcfg