Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • CacheControlHeader
  • CallableDispatcher
  • ContentDispositionHeader
  • ContentTypeHeader
  • DateHeader
  • Dispatcher
  • File
  • FileList
  • Header
  • HeaderParameter
  • Headers
  • Helpers
  • RedirectResponse
  • Request
  • Response
  • WeightedDispatcher

Interfaces

  • IDispatcher

Exceptions

  • ForceRedirect
  • HTTPError
  • MethodNotSupported
  • NotFound
  • ServiceUnavailable
  • StatusCodeNotValid

Functions

  • dispatch
  • get_dispatcher
  • get_initial_request

Class Response

A response to a HTTP request.

ICanBoogie\Object implements ICanBoogie\ToArrayRecursive uses ICanBoogie\ToArrayRecursiveTrait, ICanBoogie\PrototypeTrait
Extended by ICanBoogie\HTTP\Response

Direct known subclasses

ICanBoogie\HTTP\RedirectResponse, ICanBoogie\Operation\Response

Namespace: ICanBoogie\HTTP
See: http://tools.ietf.org/html/rfc2616
Located at vendor/icanboogie/http/lib/response.php

Methods summary

public
# __construct( mixed $body = null, integer $status = 200, ICanBoogie\HTTP\Headers|array $headers = array() )

Initializes the $body, $header, $date and $status properties.

Initializes the $body, $header, $date and $status properties.

Parameters

$body
mixed
$body The body of the response.
$status
integer
$status The status code of the response.
$headers
ICanBoogie\HTTP\Headers|array
$headers The initial header fields of the response.
public
# __set( string $property, mixed $value )

Handles read-only properties.

Handles read-only properties.

Parameters

$property
string
$property
$value
mixed
$value

Throws

ICanBoogie\PropertyNotWritable
in attempt to write one of the following properties: $is_valid, $is_informational, $is_successful, $is_redirect), {@link $is_client_error, $is_server_error, $is_ok, $is_forbidden, $is_not_found, $is_empty, $is_validateable, $is_cacheable, $is_fresh

Overrides

ICanBoogie\Object::__set
public
# __clone( )

Clones the {@link $headers] property.

Clones the {@link $headers] property.

public string
# __toString( )

Renders the response as an HTTP string.

Renders the response as an HTTP string.

Returns

string
public
# __invoke( )

Issues the HTTP response.

Issues the HTTP response.

The header is modified according to the ICanBoogie\HTTP\Response::$version, status and ICanBoogie\HTTP\Response::$status_message properties.

The usual behaviour of the response is to echo its body and then terminate the script. But if its body is null the following happens :

  • If the $location property is defined the script is terminated.
  • If the $is_ok property is falsy the method returns.

Note: If the body is a string, or an object implementing the __toString() method, the Content-Length header is automatically defined to the lenght of the body string.

Note: If the body is an instance of Closure it MUST echo the response's body.

protected
# set_status( integer|array $status )

Sets response status code and optionally status message.

Sets response status code and optionally status message.

This method is the setter for the $status property.

Parameters

$status
integer|array
$status HTTP status code or HTTP status code and HTTP status message.

Throws

InvalidArgumentException
When the HTTP status code is not valid.
protected integer
# get_status( )

Returns the response status code.

Returns the response status code.

This method is the getter for the $status property.

Returns

integer
protected
# set_body( string|Closure|null $body )

Sets the response body.

Sets the response body.

The body can be any data type that can be converted into a string this includes numeric and objects implementing the ICanBoogie\HTTP\Response::__toString() method.

Note: This method is the setter for the $body property.

Parameters

$body
string|Closure|null
$body

Throws

UnexpectedValueException
when the body cannot be converted to a string.
protected string
# get_body( )

Returns the response body.

Returns the response body.

Note: This method is the getter for the $body property.

Returns

string
protected
# echo_body( mixed $body )

Echo the body.

Echo the body.

Parameters

$body
mixed
$body
protected string
# get_status_message( )

Returns the message associated with the status code.

Returns the message associated with the status code.

This method is the volatile getter for the ICanBoogie\HTTP\Response::$status_message property and is only called if the property is not accessible.

Returns

string
protected
# set_location( string|null $url )

Sets the value of the Location header field.

Sets the value of the Location header field.

Parameters

$url
string|null
$url
protected string
# get_location( )

Returns the value of the Location header field.

Returns the value of the Location header field.

Returns

string
protected
# set_content_type( string $content_type )

Sets the value of the Content-Type header field.

Sets the value of the Content-Type header field.

Parameters

$content_type
string
$content_type
protected Headers\ContentType
# get_content_type( )

Returns the value of the Content-Type header field.

Returns the value of the Content-Type header field.

Returns

Headers\ContentType
protected
# set_content_length( integer $length )

Sets the value of the Content-Length header field.

Sets the value of the Content-Length header field.

Parameters

$length
integer
$length
protected integer
# get_content_length( )

Returns the value of the Content-Length header field.

Returns the value of the Content-Length header field.

Returns

integer
protected
# set_date( mixed $time )

Sets the value of the Date header field.

Sets the value of the Date header field.

Parameters

$time
mixed
$time
protected Headers\DateHeader
# get_date( )

Returns the value of the Date header field.

Returns the value of the Date header field.

Returns

Headers\DateHeader
protected
# set_age( integer $age )

Sets the value of the Age header field.

Sets the value of the Age header field.

Parameters

$age
integer
$age
protected integer
# get_age( )

Returns the age of the response.

Returns the age of the response.

Returns

integer
protected
# set_last_modified( mixed $time )

Sets the value of the Last-Modified header field.

Sets the value of the Last-Modified header field.

Parameters

$time
mixed
$time.
protected Headers\DateHeader
# get_last_modified( )

Returns the value of the Last-Modified header field.

Returns the value of the Last-Modified header field.

Returns

Headers\DateHeader
protected
# set_expires( mixed $time )

Sets the value of the Expires header field.

Sets the value of the Expires header field.

The method also calls the session_cache_expire() function.

Parameters

$time
mixed
$time.
protected Headers\DateHeader
# get_expires( )

Returns the value of the Expires header field.

Returns the value of the Expires header field.

Returns

Headers\DateHeader
protected
# set_etag( string $value )

Sets the value of the Etag header field.

Sets the value of the Etag header field.

Parameters

$value
string
$value
protected string
# get_etag( )

Returns the value of the Etag header field.

Returns the value of the Etag header field.

Returns

string
protected
# set_cache_control( string $cache_directives )

Sets the directives of the Cache-Control header field.

Sets the directives of the Cache-Control header field.

Parameters

$cache_directives
string
$cache_directives
protected ICanBoogie\HTTP\CacheControlHeader
# get_cache_control( )

Returns the Cache-Control header field.

Returns the Cache-Control header field.

Returns

ICanBoogie\HTTP\CacheControlHeader
protected
# set_ttl( integer $seconds )

Sets the response's time-to-live for shared caches.

Sets the response's time-to-live for shared caches.

This method adjusts the Cache-Control/s-maxage directive.

Parameters

$seconds
integer
$seconds The number of seconds.
protected integer|null
# get_ttl( )

Returns the response's time-to-live in seconds.

Returns the response's time-to-live in seconds.

When the responses TTL is <= 0, the response may not be served from cache without first revalidating with the origin.

Returns

integer|null
The number of seconds to live, or null is no freshness information is present.
protected
# set_is_private( boolean $value )

Set the cacheable property of the Cache-Control header field to private.

Set the cacheable property of the Cache-Control header field to private.

Parameters

$value
boolean
$value
protected boolean
# get_is_private( )

Checks that the cacheable property of the Cache-Control header field is private.

Checks that the cacheable property of the Cache-Control header field is private.

Returns

boolean
protected boolean
# get_is_valid( )

Checks if the response is valid.

Checks if the response is valid.

A response is considered valid when its status is between 100 and 600, 100 included.

Note: This method is the getter for the is_valid magic property.

Returns

boolean
protected boolean
# get_is_informational( )

Checks if the response is informational.

Checks if the response is informational.

A response is considered informational when its status is between 100 and 200, 100 included.

Note: This method is the getter for the is_informational magic property.

Returns

boolean
protected boolean
# get_is_successful( )

Checks if the response is successful.

Checks if the response is successful.

A response is considered successful when its status is between 200 and 300, 200 included.

Note: This method is the getter for the is_successful magic property.

Returns

boolean
protected boolean
# get_is_redirect( )

Checks if the response is a redirection.

Checks if the response is a redirection.

A response is considered to be a redirection when its status is between 300 and 400, 300 included.

Note: This method is the getter for the is_redirect magic property.

Returns

boolean
protected boolean
# get_is_client_error( )

Checks if the response is a client error.

Checks if the response is a client error.

A response is considered a client error when its status is between 400 and 500, 400 included.

Note: This method is the getter for the is_client_error magic property.

Returns

boolean
protected boolean
# get_is_server_error( )

Checks if the response is a server error.

Checks if the response is a server error.

A response is considered a server error when its status is between 500 and 600, 500 included.

Note: This method is the getter for the is_server_error magic property.

Returns

boolean
protected boolean
# get_is_ok( )

Checks if the response is ok.

Checks if the response is ok.

A response is considered ok when its status is 200.

Note: This method is the getter for the is_ok magic property.

Returns

boolean
protected boolean
# get_is_forbidden( )

Checks if the response is forbidden.

Checks if the response is forbidden.

A response is forbidden ok when its status is 403.

Note: This method is the getter for the is_forbidden magic property.

Returns

boolean
protected boolean
# get_is_not_found( )

Checks if the response is not found.

Checks if the response is not found.

A response is considered not found when its status is 404.

Note: This method is the getter for the is_not_found magic property.

Returns

boolean
protected boolean
# get_is_empty( )

Checks if the response is empty.

Checks if the response is empty.

A response is considered empty when its status is 201, 204 or 304.

Note: This method is the getter for the is_empty magic property.

Returns

boolean
protected boolean
# get_is_validateable( )

Checks that the response includes header fields that can be used to validate the response with the origin server using a conditional GET request.

Checks that the response includes header fields that can be used to validate the response with the origin server using a conditional GET request.

Returns

boolean
protected boolean
# get_is_cacheable( )

Checks that the response is worth caching under any circumstance.

Checks that the response is worth caching under any circumstance.

Responses marked _private_ with an explicit Cache-Control directive are considered uncacheable.

Responses with neither a freshness lifetime (Expires, max-age) nor cache validator (Last-Modified, ETag) are considered uncacheable.

Returns

boolean
protected boolean
# get_is_fresh( )

Checks if the response is fresh.

Checks if the response is fresh.

Returns

boolean

Methods inherited from ICanBoogie\Object

from(), resolve_facade_properties(), resolve_private_properties(), to_array(), to_json()

Methods inherited from ICanBoogie\ToArrayRecursive

to_array_recursive()

Methods used from ICanBoogie\ToArrayRecursiveTrait

to_array_recursive()

Methods used from ICanBoogie\PrototypeTrait

__call(), __get(), __sleep(), __wakeup(), get_prototype(), has_method(), has_property(), last_chance_get(), last_chance_set()

Magic methods summary

Properties summary

public static array[int]string $status_messages
#

HTTP status messages.

HTTP status messages.

public ICanBoogie\HTTP\Headers $headers
#

Response headers.

Response headers.

public string $version
#

The HTTP protocol version (1.0 or 1.1), defaults to '1.0'

The HTTP protocol version (1.0 or 1.1), defaults to '1.0'

public string $status_message
#

Message describing the status code.

Message describing the status code.

Magic properties

public integer $status
#

The HTTP status code. See: ICanBoogie\HTTP\Response::set_status() ICanBoogie\HTTP\Response::get_status()

The HTTP status code. See: ICanBoogie\HTTP\Response::set_status() ICanBoogie\HTTP\Response::get_status()

public string $status_message
#

The HTTP status message. See: set_status_message() ICanBoogie\HTTP\Response::get_status_message()

The HTTP status message. See: set_status_message() ICanBoogie\HTTP\Response::get_status_message()

public integer $ttl
#

Adjusts the s-maxage part of the Cache-Control header field definition according to the Age header field definition. See: ICanBoogie\HTTP\Response::set_ttl() ICanBoogie\HTTP\Response::get_ttl()

Adjusts the s-maxage part of the Cache-Control header field definition according to the Age header field definition. See: ICanBoogie\HTTP\Response::set_ttl() ICanBoogie\HTTP\Response::get_ttl()

public integer $age
#

Shortcut to the Age header field definition. See: ICanBoogie\HTTP\Response::set_age() ICanBoogie\HTTP\Response::get_age()

Shortcut to the Age header field definition. See: ICanBoogie\HTTP\Response::set_age() ICanBoogie\HTTP\Response::get_age()

public ICanBoogie\HTTP\CacheControlHeader $cache_control
#

Shortcut to the Cache-Control header field definition. See: ICanBoogie\HTTP\Response::set_cache_control() ICanBoogie\HTTP\Response::get_cache_control()

Shortcut to the Cache-Control header field definition. See: ICanBoogie\HTTP\Response::set_cache_control() ICanBoogie\HTTP\Response::get_cache_control()

public integer $content_length
#

Shortcut to the Content-Length header field definition. See: ICanBoogie\HTTP\Response::set_content_length() ICanBoogie\HTTP\Response::get_content_length()

Shortcut to the Content-Length header field definition. See: ICanBoogie\HTTP\Response::set_content_length() ICanBoogie\HTTP\Response::get_content_length()

public ICanBoogie\HTTP\ContentTypeHeader $content_type
#

Shortcut to the Content-Type header field definition. See: ICanBoogie\HTTP\Response::set_content_type() ICanBoogie\HTTP\Response::get_content_type()

Shortcut to the Content-Type header field definition. See: ICanBoogie\HTTP\Response::set_content_type() ICanBoogie\HTTP\Response::get_content_type()

public ICanBoogie\HTTP\DateHeader $date
#

Shortcut to the Date header field definition. See: ICanBoogie\HTTP\Response::set_date() ICanBoogie\HTTP\Response::get_date()

Shortcut to the Date header field definition. See: ICanBoogie\HTTP\Response::set_date() ICanBoogie\HTTP\Response::get_date()

public string $etag
#

Shortcut to the Etag header field definition. See: ICanBoogie\HTTP\Response::set_etag() ICanBoogie\HTTP\Response::get_etag()

Shortcut to the Etag header field definition. See: ICanBoogie\HTTP\Response::set_etag() ICanBoogie\HTTP\Response::get_etag()

public ICanBoogie\HTTP\DateHeader $expires
#

Shortcut to the Expires header field definition. See: ICanBoogie\HTTP\Response::set_expires() ICanBoogie\HTTP\Response::get_expires()

Shortcut to the Expires header field definition. See: ICanBoogie\HTTP\Response::set_expires() ICanBoogie\HTTP\Response::get_expires()

public ICanBoogie\HTTP\DateHeader $last_modified
#

Shortcut to the Last-Modified header field definition. See: ICanBoogie\HTTP\Response::set_last_modified() ICanBoogie\HTTP\Response::get_last_modified()

Shortcut to the Last-Modified header field definition. See: ICanBoogie\HTTP\Response::set_last_modified() ICanBoogie\HTTP\Response::get_last_modified()

public string $location
#

Shortcut to the Location header field definition. See: ICanBoogie\HTTP\Response::set_location() ICanBoogie\HTTP\Response::get_location()

Shortcut to the Location header field definition. See: ICanBoogie\HTTP\Response::set_location() ICanBoogie\HTTP\Response::get_location()

public string|Closure $body
#

The body of the response. See: ICanBoogie\HTTP\Response::set_body() ICanBoogie\HTTP\Response::get_body()

The body of the response. See: ICanBoogie\HTTP\Response::set_body() ICanBoogie\HTTP\Response::get_body()

public read-only boolean $is_cacheable
#

ICanBoogie\HTTP\Response::get_is_cacheable()

ICanBoogie\HTTP\Response::get_is_cacheable()

public read-only boolean $is_client_error
#

ICanBoogie\HTTP\Response::get_is_client_error()

ICanBoogie\HTTP\Response::get_is_client_error()

public read-only boolean $is_empty
#

ICanBoogie\HTTP\Response::get_is_empty()

ICanBoogie\HTTP\Response::get_is_empty()

public read-only boolean $is_forbidden
#

ICanBoogie\HTTP\Response::get_is_forbidden()

ICanBoogie\HTTP\Response::get_is_forbidden()

public read-only boolean $is_fresh
#

ICanBoogie\HTTP\Response::get_is_fresh()

ICanBoogie\HTTP\Response::get_is_fresh()

public read-only boolean $is_informational
#

ICanBoogie\HTTP\Response::get_is_informational()

ICanBoogie\HTTP\Response::get_is_informational()

public read-only boolean $is_not_found
#

ICanBoogie\HTTP\Response::get_is_not_found()

ICanBoogie\HTTP\Response::get_is_not_found()

public read-only boolean $is_ok
#

ICanBoogie\HTTP\Response::get_is_ok()

ICanBoogie\HTTP\Response::get_is_ok()

public read-only boolean $is_private
#

ICanBoogie\HTTP\Response::get_is_private()

ICanBoogie\HTTP\Response::get_is_private()

public read-only boolean $is_redirect
#

ICanBoogie\HTTP\Response::get_is_redirect()

ICanBoogie\HTTP\Response::get_is_redirect()

public read-only boolean $is_server_error
#

ICanBoogie\HTTP\Response::get_is_server_error()

ICanBoogie\HTTP\Response::get_is_server_error()

public read-only boolean $is_successful
#

ICanBoogie\HTTP\Response::get_is_successful()

ICanBoogie\HTTP\Response::get_is_successful()

public read-only boolean $is_valid
#

ICanBoogie\HTTP\Response::get_is_valid()

ICanBoogie\HTTP\Response::get_is_valid()

public read-only boolean $is_validateable
#

ICanBoogie\HTTP\Response::get_is_validateable()

ICanBoogie\HTTP\Response::get_is_validateable()

Magic properties inherited from ICanBoogie\Object

$prototype

Autodoc API documentation generated by ApiGen 2.8.0