Class Pxxo_Response

Description

Classe de Gestion de l'entete HTTP

Cette classe reprend la classe de Hugo Haas (http://larve.net/2006/08/php-http-caching/) et lui ajoute quelques bricoles

Located in /Pxxo/Response.php (line 50)


	
			
Variable Summary
Method Summary
static The etagValidator ($etag $etag)
static string formatDate (string $time)
static true isEtagWeak ($etag $etag)
bool addCookie (string $name, [string $value = ''], [int $maxage = 0], [string $path = ''], [string $domain = ''], [bool $secure = false], [bool $HTTPOnly = false])
true etagMatch ($etag $etag)
Updated freshFor ($time $time)
The getDuration ($type $type)
true isFresh ()
boolean isRedirect ()
void sendHeaders ()
void sendStatusAndHeaders ($die $die)
void setCacheDirective (string $type, boolean $set)
void setContentDirective (string $type, mixed $set)
Updated setDuration ($type $type, $time $time)
void setEtag (string $value)
void setLastModified (string $value)
void setLastModifiedFromFile (string $file)
void setRedirect (string $url, [int $code = 302])
void setWeakEtag (string $value)
Variables
mixed $ages = array(
'max-age' => -1,
's-maxage' => -1
)
(line 93)

var array Ages: max-age and s-maxage

  • access: private
array $CacheDirectives = array(
'public',
'private',
'no-cache',
'no-store',
'must-revalidate',
'proxy-revalidate',
)
(line 62)

allowed Cache Control Directives

  • access: private
array $ContentDirectives = array(
'type',
'language',
'disposition',
'transfer-encoding',
'length',
)
(line 81)

allowed Content Directives

  • access: private
array $cookies = array() (line 116)
  • var: cookies will be send
  • access: private
string $eTag (line 106)
  • access: private
string $lastModified (line 101)
  • var: Last-Modified and ETags
  • access: private
array $redirection = array() (line 111)
  • var: URL et Status Code
  • access: private
array $_CacheDirectives = array() (line 56)

Array containing the list of Cache-Control directives, except max-age and s-maxage

  • access: private
array $_ContentDirectives = array() (line 75)

Array containing the list of Cache-Control directives, except max-age and s-maxage

  • access: private
Methods
static method etagValidator (line 300)

Returns the validator value of an entity tag

  • return: validator value ($etag if the entity tag is strong, or what's after 'W/' otherwise)
static The etagValidator ($etag $etag)
  • $etag $etag: Entity tag
static method formatDate (line 479)

Format a date in RFC 1123 date format

  • return: Formatted date (e.g. "Sun, 27 Aug 2006 08:32:28 GMT")
static string formatDate (string $time)
  • string $time: Time since epoch in seconds
static method isEtagWeak (line 289)

Determines if an entity tag is weak

  • return: if the entity tag is weak, false otherwise
static true isEtagWeak ($etag $etag)
  • $etag $etag: Entity tag
addCookie (line 497)

setCookie (RFC 2109 compatible)

  • return: True or false whether the method has successfully run
bool addCookie (string $name, [string $value = ''], [int $maxage = 0], [string $path = ''], [string $domain = ''], [bool $secure = false], [bool $HTTPOnly = false])
  • string $name: Name of the cookie
  • string $value: Value of the cookie
  • int $maxage: Lifetime of the cookie
  • string $path: Path where the cookie can be used
  • string $domain: Domain which can read the cookie
  • bool $secure: Secure mode?
  • bool $HTTPOnly: Only allow HTTP usage?
etagMatch (line 264)

Compares an etag with the resource's entity tag.

  • return: if they match, false if they don't
  • access: private
true etagMatch ($etag $etag)
  • $etag $etag: Entity tag to compare
freshFor (line 383)

Set max-age and the Expires header value

  • return: value
Updated freshFor ($time $time)
  • $time $time: Duration as a positive number of seconds, a string for strtotime(), or a negative number to disable this directive
getDuration (line 337)

Get the max-age or s-maxage cache control directive value

  • return: value in seconds; if -1 is returned, no max-age directive will be sent
The getDuration ($type $type)
  • $type $type: "max-age" or "s-maxage"
isFresh (line 219)

Determines whether the client has a fresh representation of the resource.

This function compares the If-Modified-Since and If-None-Match headers provided by the client to the values specified for this resource, and returns true if the resource has been modified or false if the client's version is current.

  • return: if the version the client has is fresh, false if this is not the case and a new version needs to be returned
true isFresh ()
isRedirect (line 325)

Is there a redirection

  • access: public
boolean isRedirect ()
sendHeaders (line 156)

Send HTTP caching headers (Expires, Cache-Control, ETags and Last-Modified)

Expires and Cache-Control are sent as set.

ETag is sent if set. Last-Modified is sent if set or if ETag isn't set, defaulting to the current time. Indeed, at least you of the two needs to be present for the response to be cacheable.

void sendHeaders ()
sendStatusAndHeaders (line 128)

Send HTTP caching headers (Expires, Cache-Control, ETags and Last-Modified), and returns a 304 if the client has a cached version.

This function returns a 304 if the client already has the latest version of the resource's representation. The PHP script will subsequently quit if $die is set to true.

void sendStatusAndHeaders ($die $die)
  • $die $die: if set to true, the program terminates if a 304 is being sent, and if set to false, the call will return and the execution will continue
setCacheDirective (line 394)

Set/unset Cache-Control directive

void setCacheDirective (string $type, boolean $set)
  • string $type: Cache-Control directive (e.g. "public")
  • boolean $set: true or false to set or unset the parameter
setContentDirective (line 415)

Set/unset Content directive

void setContentDirective (string $type, mixed $set)
  • string $type: Content directive (e.g. "type")
  • mixed $set
setDuration (line 353)

Set max-age or s-maxage cache control directive value

  • return: value
Updated setDuration ($type $type, $time $time)
  • $type $type: "max-age" or "s-maxage"
  • $time $time: Duration as a positive number of seconds, a string for strtotime(), or a negative number to disable this directive
setEtag (line 432)

Set value of the ETag header The string will be quoted automatically.

void setEtag (string $value)
  • string $value: Value (string)
setLastModified (line 454)

Set value of the Last-Modified header

void setLastModified (string $value)
  • string $value: Unix timestamp
setLastModifiedFromFile (line 464)

Set value of the Last-Modified header using the last modification date of a file

void setLastModifiedFromFile (string $file)
  • string $file: File whose modification time will be used
setRedirect (line 315)

Sets Location header and response code. Forces replacement of any prior redirects.

  • access: public
void setRedirect (string $url, [int $code = 302])
  • string $url
  • int $code
setWeakEtag (line 443)

Set value of the ETag header to a weak value The string will be quoted automatically.

void setWeakEtag (string $value)
  • string $value: Value (string)

Documentation generated on Thu, 13 Mar 2008 22:03:22 +0100 by phpDocumentor 1.4.1