Final Class Yiisoft\HttpMiddleware\RemoveBodyMiddleware
| Inheritance | Yiisoft\HttpMiddleware\RemoveBodyMiddleware |
|---|---|
| Implements | Psr\Http\Server\MiddlewareInterface |
Removes the body from the response for specific HTTP status codes.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\HttpMiddleware\RemoveBodyMiddleware | |
| process() | Yiisoft\HttpMiddleware\RemoveBodyMiddleware |
Method Details
| public mixed __construct ( \Psr\Http\Message\StreamFactoryInterface $streamFactory, array $statusCodes = [ 100, // Continue 101, // Switching Protocols 102, // Processing 204, // No Content 205, // Reset Content 304, ] ) | ||
| $streamFactory | \Psr\Http\Message\StreamFactoryInterface |
Factory to create a stream. |
| $statusCodes | array |
List of HTTP status codes for which the body should be removed. |
public function __construct(
private readonly StreamFactoryInterface $streamFactory,
private readonly array $statusCodes = [
100, // Continue
101, // Switching Protocols
102, // Processing
204, // No Content
205, // Reset Content
304, // Not Modified
],
) {
}
| public \Psr\Http\Message\ResponseInterface process ( \Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Server\RequestHandlerInterface $handler ) | ||
| $request | \Psr\Http\Message\ServerRequestInterface | |
| $handler | \Psr\Http\Server\RequestHandlerInterface | |
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
return $this->shouldRemoveBody($response)
? $this->removeBody($response)
: $response;
}
Signup or Login in order to comment.