class Response

Properties

protected $content
protected $status
protected $headers

Methods

__construct(string $content = '', int $status = 200, array $headers = [])

The headers array is a set of key/value pairs. If a header is present multiple times then the value is an array of all the values.

string
__toString()

Converts the response object to string containing all headers and the response content.

string
buildHeader(string $name, string $value) deprecated

Returns the build header line.

string
getContent()

Gets the response content.

int
getStatus() deprecated

Gets the response status code.

int
getStatusCode()

No description

array
getHeaders()

Gets the response headers.

string|array
getHeader(string $header, bool $first = true)

Gets a response header.

Details

at line 36
__construct(string $content = '', int $status = 200, array $headers = [])

The headers array is a set of key/value pairs. If a header is present multiple times then the value is an array of all the values.

Parameters

string $content The content of the response
int $status The response status code
array $headers An array of headers

at line 48
string __toString()

Converts the response object to string containing all headers and the response content.

Return Value

string The response with headers and content

at line 74
protected string buildHeader(string $name, string $value) deprecated

deprecated since Symfony 4.3

Returns the build header line.

Parameters

string $name The header name
string $value The header value

Return Value

string The built header line

at line 86
string getContent()

Gets the response content.

Return Value

string The response content

at line 98
int getStatus() deprecated

deprecated since Symfony 4.3, use getStatusCode() instead

Gets the response status code.

Return Value

int The response status code

at line 105
int getStatusCode()

Return Value

int

at line 115
array getHeaders()

Gets the response headers.

Return Value

array The response headers

at line 128
string|array getHeader(string $header, bool $first = true)

Gets a response header.

Parameters

string $header The header name
bool $first Whether to return the first value or all header values

Return Value

string|array The first header value if $first is true, an array of values otherwise