Final Class Yiisoft\HttpMiddleware\HeadRequestMiddleware
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Psr\ |
Middleware removes the body from response for HEAD requests.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| process() | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $streamFactory | \ |
Factory to create a stream. |
public function __construct(
private readonly StreamFactoryInterface $streamFactory,
) {}
| public \ | ||
| $request | \ |
|
| $handler | \ |
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
if ($request->getMethod() !== 'HEAD') {
return $response;
}
return $response->withBody(
$this->streamFactory->createStream(),
);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.