Final Class Yiisoft\HttpMiddleware\RemoveBodyMiddleware
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Psr\ |
Removes the body from the response for specific HTTP status codes.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| process() | Yiisoft\ |
Method Details
| public mixed __construct ( \ 100, // Continue 101, // Switching Protocols 102, // Processing 204, // No Content 205, // Reset Content 304, ] ) | ||
| $streamFactory | \ |
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 \ | ||
| $request | \ |
|
| $handler | \ |
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
return $this->shouldRemoveBody($response)
? $this->removeBody($response)
: $response;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.