EmptyResponse

Class
extends Response
Final: Yes

Class EmptyResponse.

Description

Represents an HTTP 204 No Content response.

This class MUST be used when generating responses that intentionally contain no body content, in compliance with RFC 9110. It automatically sets the HTTP status code to 204 (No Content) and applies an optional set of headers.

Table of Contents

Methods

__construct()

Constructs a new EmptyResponse instance with optional headers.

 : mixed
Methods

__construct()

Public

Constructs a new EmptyResponse instance with optional headers.

public __construct([ array<string|int, mixed>  $headers = []]) : mixed

Description

This constructor SHALL initialize the response with HTTP status 204 and no body content. The 'reason' phrase for status 204 is automatically included based on StatusCode enumeration.

Parameters
$headers : array<string|int, mixed> = []

Description

optional headers to include in the response