Make the input preprocessors actually render an error page.
This commit is contained in:
parent
201c6e0ab3
commit
1ba9e8fa34
2 changed files with 10 additions and 14 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
0.2503.200328
|
0.2503.201929
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
// RouterProcessors.php
|
// RouterProcessors.php
|
||||||
// Created: 2025-03-15
|
// Created: 2025-03-15
|
||||||
// Updated: 2025-03-15
|
// Updated: 2025-03-20
|
||||||
|
|
||||||
namespace Index\Http\Routing;
|
namespace Index\Http\Routing;
|
||||||
|
|
||||||
|
@ -28,13 +28,11 @@ class RouterProcessors implements RouteHandler {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return void|int */
|
||||||
#[Preprocessor('input:urlencoded')]
|
#[Preprocessor('input:urlencoded')]
|
||||||
public function preInputUrlencoded(HandlerContext $context, RequestInterface $request, bool $required = true): void {
|
public function preInputUrlencoded(HandlerContext $context, RequestInterface $request, bool $required = true) {
|
||||||
if(!$this->handlePreInputUrlencoded($context, $request) && $required) {
|
if(!$this->handlePreInputUrlencoded($context, $request) && $required)
|
||||||
$context->response->statusCode = 400;
|
return 400;
|
||||||
$context->response->reasonPhrase = '';
|
|
||||||
$context->halt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function handlePreInputMultipart(HandlerContext $context, RequestInterface $request): bool {
|
private function handlePreInputMultipart(HandlerContext $context, RequestInterface $request): bool {
|
||||||
|
@ -51,8 +49,9 @@ class RouterProcessors implements RouteHandler {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return void|int */
|
||||||
#[Preprocessor('input:multipart')]
|
#[Preprocessor('input:multipart')]
|
||||||
public function preInputMultipart(HandlerContext $context, RequestInterface $request, bool $required = true): void {
|
public function preInputMultipart(HandlerContext $context, RequestInterface $request, bool $required = true) {
|
||||||
try {
|
try {
|
||||||
$result = $this->handlePreInputMultipart($context, $request);
|
$result = $this->handlePreInputMultipart($context, $request);
|
||||||
} catch(RuntimeException $ex) {
|
} catch(RuntimeException $ex) {
|
||||||
|
@ -60,11 +59,8 @@ class RouterProcessors implements RouteHandler {
|
||||||
$required = true;
|
$required = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$result && $required) {
|
if(!$result && $required)
|
||||||
$context->response->statusCode = 400;
|
return 400;
|
||||||
$context->response->reasonPhrase = '';
|
|
||||||
$context->halt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Postprocessor('output:stream')]
|
#[Postprocessor('output:stream')]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue