From c3ca98e1b35123f226c7f4c596b5dee78caa4223 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:38:42 +0200 Subject: Adding upstream version 0.11.0. Signed-off-by: Daniel Baumann --- .../src/Middleware/RequestBodyParserMiddleware.php | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 vendor/react/http/src/Middleware/RequestBodyParserMiddleware.php (limited to 'vendor/react/http/src/Middleware/RequestBodyParserMiddleware.php') diff --git a/vendor/react/http/src/Middleware/RequestBodyParserMiddleware.php b/vendor/react/http/src/Middleware/RequestBodyParserMiddleware.php new file mode 100644 index 0000000..be5ba16 --- /dev/null +++ b/vendor/react/http/src/Middleware/RequestBodyParserMiddleware.php @@ -0,0 +1,46 @@ +multipart = new MultipartParser($uploadMaxFilesize, $maxFileUploads); + } + + public function __invoke(ServerRequestInterface $request, $next) + { + $type = \strtolower($request->getHeaderLine('Content-Type')); + list ($type) = \explode(';', $type); + + if ($type === 'application/x-www-form-urlencoded') { + return $next($this->parseFormUrlencoded($request)); + } + + if ($type === 'multipart/form-data') { + return $next($this->multipart->parse($request)); + } + + return $next($request); + } + + private function parseFormUrlencoded(ServerRequestInterface $request) + { + // parse string into array structure + // ignore warnings due to excessive data structures (max_input_vars and max_input_nesting_level) + $ret = array(); + @\parse_str((string)$request->getBody(), $ret); + + return $request->withParsedBody($ret); + } +} -- cgit v1.2.3