diff --git a/VERSION b/VERSION index c5f04ce..4cdd190 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2503.230355 +0.2503.251417 diff --git a/src/Http/Content/MultipartFormContent.php b/src/Http/Content/MultipartFormContent.php index 80fc596..555e2c2 100644 --- a/src/Http/Content/MultipartFormContent.php +++ b/src/Http/Content/MultipartFormContent.php @@ -1,7 +1,7 @@ <?php // MultipartFormContent.php // Created: 2025-03-12 -// Updated: 2025-03-23 +// Updated: 2025-03-25 namespace Index\Http\Content; @@ -88,7 +88,7 @@ class MultipartFormContent implements FormContent, Iterator { /** * Parses multipart form data in a stream. * - * @param StreamInterface $stream Stream to parse, if seekable gets rewound. + * @param StreamInterface $stream Stream to parse. * @param string $boundary Boundary string. * @throws RuntimeException if the form could not be parsed correctly * @return MultipartFormContent @@ -221,9 +221,6 @@ class MultipartFormContent implements FormContent, Iterator { $params[$part->name] = [$part]; } - if($stream->isSeekable()) - $stream->rewind(); - return new MultipartFormContent($stream, $params, $files); } } diff --git a/src/Http/Content/UrlEncodedFormContent.php b/src/Http/Content/UrlEncodedFormContent.php index 9ea6c7d..d52ce51 100644 --- a/src/Http/Content/UrlEncodedFormContent.php +++ b/src/Http/Content/UrlEncodedFormContent.php @@ -1,7 +1,7 @@ <?php // UrlEncodedFormContent.php // Created: 2025-03-12 -// Updated: 2025-03-20 +// Updated: 2025-03-25 namespace Index\Http\Content; @@ -58,14 +58,10 @@ class UrlEncodedFormContent implements FormContent { /** * Parses URL encoded form params in a stream. * - * @param StreamInterface $stream Stream to parse, if seekable gets rewound. + * @param StreamInterface $stream Stream to parse. * @return UrlEncodedFormContent */ public static function parseStream(StreamInterface $stream): UrlEncodedFormContent { - $params = HttpUri::parseQueryString((string)$stream); - if($stream->isSeekable()) - $stream->rewind(); - - return new UrlEncodedFormContent($stream, $params); + return new UrlEncodedFormContent($stream, HttpUri::parseQueryString((string)$stream)); } } diff --git a/src/Http/Routing/RouterProcessors.php b/src/Http/Routing/RouterProcessors.php index e6d3aa0..897265a 100644 --- a/src/Http/Routing/RouterProcessors.php +++ b/src/Http/Routing/RouterProcessors.php @@ -1,7 +1,7 @@ <?php // RouterProcessors.php // Created: 2025-03-15 -// Updated: 2025-03-20 +// Updated: 2025-03-25 namespace Index\Http\Routing; @@ -23,7 +23,11 @@ class RouterProcessors implements RouteHandler { if(!$contentType->equals('application/x-www-form-urlencoded')) return false; - $context->deps->register(UrlEncodedFormContent::parseStream($request->getBody())); + $stream = $request->getBody(); + if($stream->isSeekable()) + $stream->rewind(); + + $context->deps->register(UrlEncodedFormContent::parseStream($stream)); return true; } @@ -44,7 +48,11 @@ class RouterProcessors implements RouteHandler { if(empty($boundary)) return false; - $context->deps->register(MultipartFormContent::parseStream($request->getBody(), $boundary)); + $stream = $request->getBody(); + if($stream->isSeekable()) + $stream->rewind(); + + $context->deps->register(MultipartFormContent::parseStream($stream, $boundary)); return true; }