class LeftAndMain_HTTPResponse extends HTTPResponse

Allow overriding finished state for faux redirects.

Traits

A class that can be instantiated or replaced via DI

Methods

static Injectable
create(array $args)

An implementation of the factory method, allows you to create an instance of a class

static Injectable
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

__construct(string $body = null, int $statusCode = null, string $statusDescription = null, string $protocolVersion = null)

Create a new HTTP response

$this
setProtocolVersion(string $protocolVersion)

The HTTP version used to respond to this request (typically 1.0 or 1.1)

$this
setStatusCode(int $code, string $description = null)

No description

$this
setStatusDescription(string $description)

The text to be given alongside the status code ("reason phrase").

string
getProtocolVersion()

No description

int
getStatusCode()

No description

string
getStatusDescription()

No description

bool
isError()

Returns true if this HTTP response is in error

$this
setBody(string $body)

No description

string
getBody()

No description

$this
addHeader(string $header, string $value)

Add a HTTP header to the response, replacing any header of the same name.

string
getHeader(string $header)

Return the HTTP header of the given name.

array
getHeaders()

No description

$this
removeHeader(string $header)

Remove an existing HTTP header by its name, e.g. "Content-Type".

$this
redirect(string $dest, int $code = 302)

No description

output()

Send this HTTPResponse to the browser

bool
isFinished()

Returns true if this response is "finished", that is, no more script execution should be done.

bool
isRedirect()

Determine if this response is a redirect

string
__toString()

The HTTP response represented as a raw string

setIsFinished($bool)

No description

Details

in Injectable at line 26
static Injectable create(array $args)

An implementation of the factory method, allows you to create an instance of a class

This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.

This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create('SiteTree'); $list = SiteTree::get();

Parameters

array $args

Return Value

Injectable

in Injectable at line 43
static Injectable singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).

Parameters

string $class Optional classname to create, if the called class should not be used

Return Value

Injectable The singleton instance

in HTTPResponse at line 137
__construct(string $body = null, int $statusCode = null, string $statusDescription = null, string $protocolVersion = null)

Create a new HTTP response

Parameters

string $body The body of the response
int $statusCode The numeric status code - 200, 404, etc
string $statusDescription The text to be given alongside the status code. See {@link setStatusCode()} for more information.
string $protocolVersion

in HTTPResponse at line 160
$this setProtocolVersion(string $protocolVersion)

The HTTP version used to respond to this request (typically 1.0 or 1.1)

Parameters

string $protocolVersion

Return Value

$this

in HTTPResponse at line 175
$this setStatusCode(int $code, string $description = null)

Parameters

int $code
string $description Optional. See {@link setStatusDescription()}. No newlines are allowed in the description. If omitted, will default to the standard HTTP description for the given $code value (see {@link $status_codes}).

Return Value

$this

in HTTPResponse at line 199
$this setStatusDescription(string $description)

The text to be given alongside the status code ("reason phrase").

Caution: Will be overwritten by {@link setStatusCode()}.

Parameters

string $description

Return Value

$this

in HTTPResponse at line 208
string getProtocolVersion()

Return Value

string

in HTTPResponse at line 216
int getStatusCode()

Return Value

int

in HTTPResponse at line 224
string getStatusDescription()

Return Value

string Description for a HTTP status code

in HTTPResponse at line 234
bool isError()

Returns true if this HTTP response is in error

Return Value

bool

in HTTPResponse at line 245
$this setBody(string $body)

Parameters

string $body

Return Value

$this

in HTTPResponse at line 254
string getBody()

Return Value

string

in HTTPResponse at line 267
$this addHeader(string $header, string $value)

Add a HTTP header to the response, replacing any header of the same name.

Parameters

string $header Example: "content-type"
string $value Example: "text/xml"

Return Value

$this

in HTTPResponse at line 281
string getHeader(string $header)

Return the HTTP header of the given name.

Parameters

string $header

Return Value

string

in HTTPResponse at line 293
array getHeaders()

Return Value

array

in HTTPResponse at line 306
$this removeHeader(string $header)

Remove an existing HTTP header by its name, e.g. "Content-Type".

Parameters

string $header

Return Value

$this

in HTTPResponse at line 319
$this redirect(string $dest, int $code = 302)

Parameters

string $dest
int $code

Return Value

$this

in HTTPResponse at line 333
output()

Send this HTTPResponse to the browser

at line 15
bool isFinished()

Returns true if this response is "finished", that is, no more script execution should be done.

Specifically, returns true if a redirect has already been requested

Return Value

bool

in HTTPResponse at line 439
bool isRedirect()

Determine if this response is a redirect

Return Value

bool

in HTTPResponse at line 449
string __toString()

The HTTP response represented as a raw string

Return Value

string

at line 20
setIsFinished($bool)

Parameters

$bool