class JResponse

JResponse Class.

This class serves to provide the Joomla Platform with a common interface to access response variables. This includes header and body.

Methods

static  boolean
allowCache( boolean $allow = null)

Set/get cachable state for the response.

static  void
setHeader( string $name, string $value, boolean $replace = false)

Set a header.

static  array
getHeaders()

Return array of headers.

static  void
clearHeaders()

Clear headers.

static  void
sendHeaders()

Send all headers.

static  void
setBody( string $content)

Set body content.

static  void
prependBody( string $content)

Prepend content to the body content

static  void
appendBody( string $content)

Append content to the body content

static  string
getBody( boolean $toArray = false)

Return the body content

static  string
toString( boolean $compress = false)

Sends all headers prior to returning the string

Details

static boolean allowCache( boolean $allow = null)

Set/get cachable state for the response.

If $allow is set, sets the cachable state of the response. Always returns current state.

Parameters

boolean $allow True to allow browser caching.

Return Value

boolean True if browser caching should be allowed

static void setHeader( string $name, string $value, boolean $replace = false)

Set a header.

If $replace is true, replaces any headers already defined with that $name.

Parameters

string $name The name of the header to set.
string $value The value of the header to set.
boolean $replace True to replace any existing headers by name.

Return Value

void

static array getHeaders()

Return array of headers.

Return Value

array

static void clearHeaders()

Clear headers.

Return Value

void

static void sendHeaders()

Send all headers.

Return Value

void

static void setBody( string $content)

Set body content.

If body content already defined, this will replace it.

Parameters

string $content The content to set to the response body.

Return Value

void

static void prependBody( string $content)

Prepend content to the body content

Parameters

string $content The content to prepend to the response body.

Return Value

void

static void appendBody( string $content)

Append content to the body content

Parameters

string $content The content to append to the response body.

Return Value

void

static string getBody( boolean $toArray = false)

Return the body content

Parameters

boolean $toArray Whether or not to return the body content as an array of strings or as a single string; defaults to false.

Return Value

string array

static string toString( boolean $compress = false)

Sends all headers prior to returning the string

Parameters

boolean $compress If true, compress the data

Return Value

string