HTTP Error bad request 400 with custom "Server:" header? #569
-
Hi! I'm searching for a way to modify the response object when the HTTP request is malformed. I believe it is coming from: That is calling That is calling the generic Any way to get this to add my own My code snippet is here: $http = new HttpServer(
new PSR15Middleware($accessLog),
async(
static function (ServerRequestInterface $request) use ($config): ResponseInterface {
$response = new Response(200, [
'Server' => 'My Own Server Header',
]);
<!-- snip -->
}
)
); The 'error' only has Throwable handling but no response object. $http->on(
'error',
static function (Throwable $e) use ($config): void {
$config->logger->error('{message}' . \PHP_EOL, [
'message' => $e->getMessage(),
]);
$config->logger->debug($e->getTraceAsString());
}
); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In short, you cannot. As you already found out, the 400 response happens before any middleware/request handlers come into play. What we can consider adding is a configuration middleware to |
Beta Was this translation helpful? Give feedback.
In short, you cannot. As you already found out, the 400 response happens before any middleware/request handlers come into play. What we can consider adding is a configuration middleware to
react/http
handling this.