ICanBoogie/HTTP master
  • Namespace
  • Class

Namespaces

  • ICanBoogie
    • Exception
    • HTTP
      • Headers
      • Request
      • RequestDispatcher

Classes

  • CallableDispatcher
  • DispatcherProvider
  • File
  • FileInfo
  • FileList
  • FileResponse
  • Headers
  • ProvideDispatcher
  • RedirectResponse
  • Request
  • RequestDispatcher
  • RequestOptionsMapper
  • RequestRange
  • Response
  • Status
  • WeightedDispatcher

Interfaces

  • Dispatcher
  • Exception
  • FileOptions
  • RequestMethods
  • RequestOptions
  • ResponseStatus
  • SecurityError

Exceptions

  • AuthenticationRequired
  • ClientError
  • DispatcherNotDefined
  • DispatcherProviderNotDefined
  • ForceRedirect
  • MethodNotSupported
  • NotFound
  • PermissionRequired
  • ServerError
  • ServiceUnavailable
  • StatusCodeNotValid

Functions

  • dispatch
  • get_dispatcher
  • get_initial_request

Class Response

A response to a HTTP request.

ICanBoogie\HTTP\Response implements ICanBoogie\HTTP\ResponseStatus uses ICanBoogie\Accessor\AccessorTrait (not available)

Direct known subclasses

ICanBoogie\HTTP\FileResponse, ICanBoogie\HTTP\RedirectResponse

Namespace: ICanBoogie\HTTP
See: http://tools.ietf.org/html/rfc2616
Located at Response.php

Methods summary

public
# __construct( mixed $body = null, integer|ICanBoogie\HTTP\Status $status = self::STATUS_OK, ICanBoogie\HTTP\Headers|array $headers = [] )

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

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

Parameters

$body
The body of the response.
$status
The status code of the response.
$headers
The initial header fields of the response.
public
# __clone( )

Clones the ICanBoogie\HTTP\Response::$headers and $status properties.

Clones the ICanBoogie\HTTP\Response::$headers and $status properties.

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.

ICanBoogie\HTTP\Response::finalize() is invoked to finalize the headers (a cloned actually) and the body. ICanBoogie\HTTP\Response::send_headers() is invoked to send the headers and ICanBoogie\HTTP\Response::send_body() is invoked to send the body, if the body is not null.

The body is not send in the following instances:

  • The finalized body is null.
  • The status is not ok.
protected
# finalize( ICanBoogie\HTTP\Headers & $headers, mixed & $body )

Finalize the body.

Finalize the body.

Subclasses might want to override this method if they wish to alter the header or the body before the response is sent or transformed into a string.

Parameters

$headers
Reference to the final header.
$body
Reference to the final body.
protected
# send_headers( ICanBoogie\HTTP\Headers $headers )
protected
# send_body( mixed $body )

Sends response body.

Sends response body.

Parameters

$body
protected
# set_status( integer|ICanBoogie\HTTP\Status $status )

Sets response status code and optionally status message.

Sets response status code and optionally status message.

Parameters

$status
HTTP status code or HTTP status code and HTTP status message.
protected ICanBoogie\HTTP\Status
# get_status( )

Returns the response status.

Returns the response status.

Returns

ICanBoogie\HTTP\Status
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.

Parameters

$body

Throws

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

Asserts that the a body is valid.

Asserts that the a body is valid.

Parameters

$body

Throws

UnexpectedValueException
if the specified body doesn't meet the requirements.
protected string
# get_body( )

Returns the response body.

Returns the response body.

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
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
protected ICanBoogie\HTTP\Headers\ContentType
# get_content_type( )

Returns the value of the Content-Type header field.

Returns the value of the Content-Type header field.

Returns

ICanBoogie\HTTP\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
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
protected ICanBoogie\HTTP\Headers\Date
# get_date( )

Returns the value of the Date header field.

Returns the value of the Date header field.

Returns

ICanBoogie\HTTP\Headers\Date
protected
# set_age( integer $age )

Sets the value of the Age header field.

Sets the value of the Age header field.

Parameters

$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
protected ICanBoogie\HTTP\Headers\Date
# get_last_modified( )

Returns the value of the Last-Modified header field.

Returns the value of the Last-Modified header field.

Returns

ICanBoogie\HTTP\Headers\Date
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
protected ICanBoogie\HTTP\Headers\Date
# get_expires( )

Returns the value of the Expires header field.

Returns the value of the Expires header field.

Returns

ICanBoogie\HTTP\Headers\Date
protected
# set_etag( string $value )

Sets the value of the ETag header field.

Sets the value of the ETag header field.

Parameters

$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
protected ICanBoogie\HTTP\Headers\CacheControl
# get_cache_control( )

Returns the Cache-Control header field.

Returns the Cache-Control header field.

Returns

ICanBoogie\HTTP\Headers\CacheControl
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
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 re-validating with the origin.

Returns

integer|null

The number of seconds to live, or null is no freshness information is present.

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 not cacheable.

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

Returns

boolean
protected boolean
# get_is_fresh( )

Checks if the response is fresh.

Checks if the response is fresh.

Returns

boolean

Constants summary

Constants inherited from ICanBoogie\HTTP\ResponseStatus

STATUS_ACCEPTED, STATUS_BAD_GATEWAY, STATUS_BAD_REQUEST, STATUS_CONFLICT, STATUS_CONTINUE, STATUS_CREATED, STATUS_EXPECTATION_FAILED, STATUS_FORBIDDEN, STATUS_FOUND, STATUS_GATEWAY_TIMEOUT, STATUS_GONE, STATUS_HTTP_VERSION_NOT_SUPPORTED, STATUS_INTERNAL_SERVER_ERROR, STATUS_I_M_A_TEAPOT, STATUS_LENGTH_REQUIRED, STATUS_METHOD_NOT_ALLOWED, STATUS_MOVED_PERMANENTLY, STATUS_MULTIPLE_CHOICES, STATUS_NON_AUTHORITATIVE_INFORMATION, STATUS_NOT_ACCEPTABLE, STATUS_NOT_FOUND, STATUS_NOT_IMPLEMENTED, STATUS_NOT_MODIFIED, STATUS_NO_CONTENT, STATUS_OK, STATUS_PARTIAL_CONTENT, STATUS_PAYMENT_REQUIRED, STATUS_PRECONDITION_FAILED, STATUS_PROXY_AUTHENTICATION_REQUIRED, STATUS_REQUESTED_RANGE_NOT_SATISFIABLE, STATUS_REQUEST_ENTITY_TOO_LARGE, STATUS_REQUEST_TIMEOUT, STATUS_REQUEST_URI_TOO_LONG, STATUS_RESET_CONTENT, STATUS_SEE_OTHER, STATUS_SERVICE_UNAVAILABLE, STATUS_SWITCHING_PROTOCOLS, STATUS_TEMPORARY_REDIRECT, STATUS_UNAUTHORIZED, STATUS_UNSUPPORTED_MEDIA_TYPE, STATUS_USE_PROXY

Properties summary

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'

# '1.0'

Magic properties

public ICanBoogie\HTTP\Status $status
public mixed $body

The body of the response.

public integer $ttl

Adjusts the s-maxage part of the Cache-Control header field definition according to the Age header field definition.

public integer $age

Shortcut to the Age header field definition.

public ICanBoogie\HTTP\Headers\CacheControl $cache_control

Shortcut to the Cache-Control header field definition.

public integer $content_length

Shortcut to the Content-Length header field definition.

public ICanBoogie\HTTP\Headers\ContentType $content_type

Shortcut to the Content-Type header field definition.

public ICanBoogie\HTTP\Headers\Date $date

Shortcut to the Date header field definition.

public string $etag

Shortcut to the ETag header field definition.

public ICanBoogie\HTTP\Headers\Date $expires

Shortcut to the Expires header field definition.

public ICanBoogie\HTTP\Headers\Date $last_modified

Shortcut to the Last-Modified header field definition.

public string $location

Shortcut to the Location header field definition.

public read-only boolean $is_cacheable

ICanBoogie\HTTP\Response::get_is_cacheable()

public read-only boolean $is_fresh

ICanBoogie\HTTP\Response::get_is_fresh()

public read-only boolean $is_private

get_is_private()

public read-only boolean $is_validateable

ICanBoogie\HTTP\Response::get_is_validateable()

ICanBoogie/HTTP master API documentation generated by ApiGen