Class jResponse

Description

base class for response object A response object is responsible to generate a content in a specific format.

  • abstract:

Located in /core/jResponse.class.php (line 21)


	
			
Direct descendents
Class Description
jResponseJson Json response
jResponseZip generate a zip content and send it to the browser
jResponseText plain Text response
jResponseCmdline Command line response
jResponseXMLFeed Responses for Syndication should inherits from jResponseXMLFeed
jResponseRedirectUrl Response To redirect to an URL
jResponseCss Send CSS content
jResponseBasicHtml Basic HTML response. the HTML content should be provided by a simple php file.
jResponseRedirect Response To redirect to an action
jResponseXmlRpc xmlrpc response
jResponseHtmlFragment Send Html part
jResponseBinary Response use to send a binary file to the browser
jResponseSitemap Sitemap 0.9 response
jResponseXml XML response generator
jResponseJsonRpc Response for jsonrpc protocol
Variable Summary
Method Summary
jResponse __construct ()
void addHttpHeader (string $htype, string $hcontent, [integer $overwrite = true])
string getFormatType ()
string getType ()
boolean isValidCache ([mixed $dateLastModified = null], [ $etag = null], [boolean $cleanCacheHeader = true])
boolean output ()
void outputErrors ()
void sendHttpHeaders ()
void setExpires ( $date, [ $cleanCacheHeader = true], mixed $dateLastModified, boolean $cleanCacheHeaderTrue)
void setHttpStatus (string $code, string $msg)
void setLifetime (int $time, [boolean $sharedCache = false], [ $cleanCacheHeader = true], boolean $cleanCacheHeaderTrue)
string _normalizeDate (mixed $date)
Variables
mixed $forcedHttpVersion = false (line 54)
  • access: public
mixed $httpVersion = '1.1' (line 53)
  • access: public
array $_httpHeaders = array() (line 31)
  • var: list of http headers that will be send to the client
  • access: protected
boolean $_httpHeadersSent = false (line 36)
  • var: indicates if http headers have already been sent to the client
  • access: protected
string $_httpStatusCode = '200' (line 41)
  • var: the http status code to send
  • access: protected
string $_httpStatusMsg = 'OK' (line 45)
  • var: the http status message to send
  • access: protected
boolean $_outputOnlyHeaders = false (line 50)
  • var: Should we output only the headers or the entire response
  • access: protected
Methods
Constructor __construct (line 59)

constructor

jResponse __construct ()

Redefined in descendants as:
addHttpHeader (line 117)

add an http header to the response.

will be send during the output of the response

  • access: public
void addHttpHeader (string $htype, string $hcontent, [integer $overwrite = true])
  • string $htype: the header type ("Content-Type", "Date-modified"...)
  • string $hcontent: value of the header type
  • integer $overwrite: false or 0 if the value should be set only if it doesn't still exist -1 to add the header with the existing values true or 1 to replace the existing header
cleanCacheHeaders (line 209)

Clean the differents caches headers

  • access: public
void cleanCacheHeaders ()
clearHttpHeaders (line 137)

delete all http headers

  • access: public
void clearHttpHeaders ()
getFormatType (line 106)

return the format type name (eg the family type name)

  • return: the name
  • access: public
string getFormatType ()

Redefined in descendants as:
getType (line 100)

return the response type name

  • return: the name
  • access: public
string getType ()
isValidCache (line 268)

Use the HTPP headers Last-Modified to see if the ressource in client cache is fresh

  • return: True if the client ressource version is fresh, false otherwise
  • access: public
boolean isValidCache ([mixed $dateLastModified = null], [ $etag = null], [boolean $cleanCacheHeader = true])
  • mixed $dateLastModified: Can be a jDateTime object, a DateTime object or a string understandable by strtotime
  • boolean $cleanCacheHeader: True for clean/delete other cache headers. Default : true.
  • $etag
output (line 76)

Send the response in the correct format. If errors or exceptions appears during this method, outputErrors will be called. So the the content should be generated using the output buffer if errors can be appeared during this generation. Be care of http headers.

  • return: true if the output is ok
  • abstract:
  • access: public
boolean output ()

Redefined in descendants as:
outputErrors (line 81)

Send a response with a generic error message.

  • access: public
void outputErrors ()

Redefined in descendants as:
sendHttpHeaders (line 153)

send http headers

  • access: protected
void sendHttpHeaders ()

Redefined in descendants as:
setExpires (line 226)

Set an expires header to the page/ressource.

void setExpires ( $date, [ $cleanCacheHeader = true], mixed $dateLastModified, boolean $cleanCacheHeaderTrue)
  • mixed $dateLastModified: Can be a jDateTime object, a DateTime object or a string understandable by strtotime
  • boolean $cleanCacheHeaderTrue: for clean/delete other cache headers. Default : true.
  • $date
  • $cleanCacheHeader
setHttpStatus (line 148)

set the http status code for the http header

  • access: public
void setHttpStatus (string $code, string $msg)
  • string $code: the status code (200, 404...)
  • string $msg: the message following the status code ("OK", "Not Found"..)
setLifetime (line 247)

Set a life time for the page/ressource.

  • access: public
void setLifetime (int $time, [boolean $sharedCache = false], [ $cleanCacheHeader = true], boolean $cleanCacheHeaderTrue)
  • int $time: Time during which the page will be cached. Express in seconds.
  • boolean $sharedCache: True if the lifetime concern a public/shared cache. Default : false.
  • boolean $cleanCacheHeaderTrue: for clean/delete other cache headers. Default : true.
  • $cleanCacheHeader
_checkRequestType (line 191)

check if the request is of type GET or HEAD

  • access: protected
void _checkRequestType ()
_normalizeDate (line 176)

Normalize a date into GMT format

  • return: a date in GMT format
  • access: protected
string _normalizeDate (mixed $date)
  • mixed $date: Can be a jDateTime object, a DateTime object or a string understandable by strtotime

Documentation generated on Wed, 04 Jan 2017 22:56:04 +0100 by phpDocumentor 1.4.3