Response
Response
class Response implements \ArrayAccessProperties
status
public int $statusname
The status message associated with the response code (e.g., "OK", "Not Found").
public string $nameversion
The HTTP version of the response (e.g., "HTTP/1.1").
public string $versionbody
public string $bodycontentLength
The length of the response body in bytes.
public int $contentLengthbytesRemaining
The number of bytes remaining to be read from the response body.
public int $bytesRemaining = -1headers
public array $headersbuffer
public string $bufferheadersParsed
Indicates whether the response headers have been parsed.
private bool $headersParsedchunked
Indicates whether the response uses chunked transfer encoding.
private bool $chunkedchunkOffset
The offset for the current chunk when parsing chunked data.
private int $chunkOffsetMethods
__construct
public __construct(?int $status, array $headers, string $version = 'HTTP/1.1'): voidParameters
| Parameter | Type | Description |
|---|---|---|
$status | int | |
$headers | array | |
$version | string |
offsetGet
ArrayAccess method to allow access to headers as properties.
public offsetGet(mixed $offset): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
offsetSet
ArrayAccess method to allow access to headers as properties.
public offsetSet(mixed $offset, mixed $value): voidParameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed | |
$value | mixed | The value to set |
offsetExists
ArrayAccess method to allow access to headers as properties.
public offsetExists(mixed $offset): boolParameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
offsetUnset
ArrayAccess method to allow access to headers as properties.
public offsetUnset(mixed $offset): voidParameters
| Parameter | Type | Description |
|---|---|---|
$offset | mixed |
setStatus
Sets the HTTP status code and updates the status message.
public setStatus(int $status): voidParameters
| Parameter | Type | Description |
|---|---|---|
$status | int | the HTTP status code to set |
write
Appends data to the response body and updates the content length.
public write(string $string): voidParameters
| Parameter | Type | Description |
|---|---|---|
$string | string | the data to append to the response body |
read
Reads and parses data from the response buffer.
public read(string $buffer): boolHandles header parsing, chunked transfer decoding, and body accumulation. Returns true when the response is fully read.
Parameters
| Parameter | Type | Description |
|---|---|---|
$buffer | string | the buffer data to read and parse |
hasHeader
Checks if a header exists in the response.
public hasHeader(string $key): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | the header key to check |
getHeader
Get a header from the response.
public getHeader(string $header, null $): voidParameters
| Parameter | Type | Description |
|---|---|---|
$header | string | The header key to get |
$ | null |
setHeader
Sets or removes a header in the response.
public setHeader(string $header, ?string $content): voidIf content is null, the header is removed. Otherwise, the header is set to the provided value.
Parameters
| Parameter | Type | Description |
|---|---|---|
$header | string | the header key to set or remove |
$content | string | the value to set, or null to remove the header |
size
Returns the size of the response body in bytes.
public size(): inttoString
Converts the response object to its string representation as a raw HTTP response.
public toString(): stringIncludes the status line, headers, and body, formatted according to HTTP/1.1 standards.
getStatusMessage
public getStatusMessage(?int $code): stringParameters
| Parameter | Type | Description |
|---|---|---|
$code | int |
getContentType
Get the content type of the response.
public getContentType(array $args): stringThis method will return the content type of the response and optionally return any arguments that were
Parameters
| Parameter | Type | Description |
|---|---|---|
$args | array | The arguments of the content type header will be returned in this array |
body
public body(bool $raw): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$raw | bool |
getText
Helper function to get the status text for an HTTP response code.
public getText(int $code): voidParameters
| Parameter | Type | Description |
|---|---|---|
$code | int | the response code |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000