|
@@ -17,7 +17,21 @@ class MultipartFormDataParser
|
|
|
if ($boundary === '') {
|
|
if ($boundary === '') {
|
|
|
throw new \RuntimeException('Missing multipart boundary');
|
|
throw new \RuntimeException('Missing multipart boundary');
|
|
|
}
|
|
}
|
|
|
- $rawBody = (string)$request->getBody();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $rawBody = '';
|
|
|
|
|
+ $stream = $request->getBody();
|
|
|
|
|
+ if (is_object($stream) && method_exists($stream, 'getContents')) {
|
|
|
|
|
+ $rawBody = (string)$stream->getContents();
|
|
|
|
|
+ if (method_exists($stream, 'rewind')) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ $stream->rewind();
|
|
|
|
|
+ } catch (\Throwable $e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $rawBody = (string)$stream;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if ($rawBody === '') {
|
|
if ($rawBody === '') {
|
|
|
$rawBody = (string)file_get_contents('php://input');
|
|
$rawBody = (string)file_get_contents('php://input');
|
|
|
}
|
|
}
|
|
@@ -29,8 +43,8 @@ class MultipartFormDataParser
|
|
|
$files = [];
|
|
$files = [];
|
|
|
|
|
|
|
|
foreach ($parts as $part) {
|
|
foreach ($parts as $part) {
|
|
|
- $part = ltrim($part, "\r\n");
|
|
|
|
|
- $part = rtrim($part, "\r\n");
|
|
|
|
|
|
|
+ $part = ltrim($part, "\r\n\n");
|
|
|
|
|
+ $part = rtrim($part, "\r\n\n");
|
|
|
|
|
|
|
|
if ($part === '' || $part === '--') {
|
|
if ($part === '' || $part === '--') {
|
|
|
continue;
|
|
continue;
|