Overview

Namespaces

  • Composer
    • Autoload
  • Guzzle
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Mock
    • Stream
  • Mockery
    • Adapter
      • Phpunit
    • CountValidator
    • Exception
    • Generator
      • StringManipulation
        • Pass
    • Loader
    • Matcher
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • Fatzebra
      • Message
  • PHP
  • Symfony
    • Component
      • EventDispatcher
        • Debug
        • DependencyInjection
        • Tests
          • Debug
          • DependencyInjection
      • HttpFoundation
        • File
          • Exception
          • MimeType
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
        • Tests
          • File
            • MimeType
          • Session
            • Attribute
            • Flash
            • Storage
              • Handler
              • Proxy
      • Yaml
        • Exception
        • Tests

Classes

  • AcceptHeader
  • AcceptHeaderItem
  • ApacheRequest
  • BinaryFileResponse
  • Cookie
  • ExpressionRequestMatcher
  • FileBag
  • HeaderBag
  • IpUtils
  • JsonResponse
  • ParameterBag
  • RedirectResponse
  • Request
  • RequestMatcher
  • RequestStack
  • Response
  • ResponseHeaderBag
  • ServerBag
  • StreamedResponse

Interfaces

  • RequestMatcherInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class Response

Response represents an HTTP response.

Direct known subclasses

Symfony\Component\HttpFoundation\BinaryFileResponse, Symfony\Component\HttpFoundation\JsonResponse, Symfony\Component\HttpFoundation\RedirectResponse, Symfony\Component\HttpFoundation\StreamedResponse
Namespace: Symfony\Component\HttpFoundation
Author: Fabien Potencier fabien@symfony.com
Api
Located at Response.php
Methods summary
public
# __construct( mixed $content = '', integer $status = 200, array $headers = array() )

Constructor.

Constructor.

Parameters

$content
The response content, see setContent()
$status
The response status code
$headers
An array of response headers

Throws

InvalidArgumentException
When the HTTP status code is not valid

Api

public static Symfony\Component\HttpFoundation\Response
# create( mixed $content = '', integer $status = 200, array $headers = array() )

Factory method for chainability.

Factory method for chainability.

Example: return Response::create($body, 200) ->setSharedMaxAge(300);

Parameters

$content
The response content, see setContent()
$status
The response status code
$headers
An array of response headers

Returns

Symfony\Component\HttpFoundation\Response
public string
# __toString( )

Returns the Response as an HTTP string.

Returns the Response as an HTTP string.

The string representation of the Response is the same as the one that will be sent to the client only if the prepare() method has been called before.

Returns

string
The Response as an HTTP string

See

Symfony\Component\HttpFoundation\Response::prepare()
public
# __clone( )

Clones the current Response instance.

Clones the current Response instance.

public Symfony\Component\HttpFoundation\Response
# prepare( Symfony\Component\HttpFoundation\Request $request )

Prepares the Response before it is sent to the client.

Prepares the Response before it is sent to the client.

This method tweaks the Response to ensure that it is compliant with RFC 2616. Most of the changes are based on the Request that is "associated" with this Response.

Parameters

$request
A Request instance

Returns

Symfony\Component\HttpFoundation\Response
The current response.
public Symfony\Component\HttpFoundation\Response
# sendHeaders( )

Sends HTTP headers.

Sends HTTP headers.

Returns

Symfony\Component\HttpFoundation\Response
public Symfony\Component\HttpFoundation\Response
# sendContent( )

Sends content for the current web response.

Sends content for the current web response.

Returns

Symfony\Component\HttpFoundation\Response
public Symfony\Component\HttpFoundation\Response
# send( )

Sends HTTP headers and content.

Sends HTTP headers and content.

Returns

Symfony\Component\HttpFoundation\Response

Api

public Symfony\Component\HttpFoundation\Response
# setContent( mixed $content )

Sets the response content.

Sets the response content.

Valid types are strings, numbers, null, and objects that implement a __toString() method.

Parameters

$content
Content that can be cast to string

Returns

Symfony\Component\HttpFoundation\Response

Throws

UnexpectedValueException

Api

public string
# getContent( )

Gets the current response content.

Gets the current response content.

Returns

string
Content

Api

public Symfony\Component\HttpFoundation\Response
# setProtocolVersion( string $version )

Sets the HTTP protocol version (1.0 or 1.1).

Sets the HTTP protocol version (1.0 or 1.1).

Parameters

$version
The HTTP protocol version

Returns

Symfony\Component\HttpFoundation\Response

Api

public string
# getProtocolVersion( )

Gets the HTTP protocol version.

Gets the HTTP protocol version.

Returns

string
The HTTP protocol version

Api

public Symfony\Component\HttpFoundation\Response
# setStatusCode( integer $code, mixed $text = null )

Sets the response status code.

Sets the response status code.

Parameters

$code
HTTP status code
$text

HTTP status text

If the status text is null it will be automatically populated for the known status codes and left empty otherwise.

Returns

Symfony\Component\HttpFoundation\Response

Throws

InvalidArgumentException
When the HTTP status code is not valid

Api

public integer
# getStatusCode( )

Retrieves the status code for the current web response.

Retrieves the status code for the current web response.

Returns

integer
Status code

Api

public Symfony\Component\HttpFoundation\Response
# setCharset( string $charset )

Sets the response charset.

Sets the response charset.

Parameters

$charset
Character set

Returns

Symfony\Component\HttpFoundation\Response

Api

public string
# getCharset( )

Retrieves the response charset.

Retrieves the response charset.

Returns

string
Character set

Api

public boolean
# isCacheable( )

Returns true if the response is worth caching under any circumstance.

Returns true if 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
true if the response is worth caching, false otherwise

Api

public boolean
# isFresh( )

Returns true if the response is "fresh".

Returns true if the response is "fresh".

Fresh responses may be served from cache without any interaction with the origin. A response is considered fresh when it includes a Cache-Control/max-age indicator or Expires header and the calculated age is less than the freshness lifetime.

Returns

boolean
true if the response is fresh, false otherwise

Api

public boolean
# isValidateable( )

Returns true if the response includes headers that can be used to validate the response with the origin server using a conditional GET request.

Returns true if the response includes headers that can be used to validate the response with the origin server using a conditional GET request.

Returns

boolean
true if the response is validateable, false otherwise

Api

public Symfony\Component\HttpFoundation\Response
# setPrivate( )

Marks the response as "private".

Marks the response as "private".

It makes the response ineligible for serving other clients.

Returns

Symfony\Component\HttpFoundation\Response

Api

public Symfony\Component\HttpFoundation\Response
# setPublic( )

Marks the response as "public".

Marks the response as "public".

It makes the response eligible for serving other clients.

Returns

Symfony\Component\HttpFoundation\Response

Api

public boolean
# mustRevalidate( )

Returns true if the response must be revalidated by caches.

Returns true if the response must be revalidated by caches.

This method indicates that the response must not be served stale by a cache in any circumstance without first revalidating with the origin. When present, the TTL of the response should not be overridden to be greater than the value provided by the origin.

Returns

boolean
true if the response must be revalidated by a cache, false otherwise

Api

public DateTime
# getDate( )

Returns the Date header as a DateTime instance.

Returns the Date header as a DateTime instance.

Returns

DateTime
A \DateTime instance

Throws

RuntimeException
When the header is not parseable

Api

public Symfony\Component\HttpFoundation\Response
# setDate( DateTime $date )

Sets the Date header.

Sets the Date header.

Parameters

$date
A \DateTime instance

Returns

Symfony\Component\HttpFoundation\Response

Api

public integer
# getAge( )

Returns the age of the response.

Returns the age of the response.

Returns

integer
The age of the response in seconds
public Symfony\Component\HttpFoundation\Response
# expire( )

Marks the response stale by setting the Age header to be equal to the maximum age of the response.

Marks the response stale by setting the Age header to be equal to the maximum age of the response.

Returns

Symfony\Component\HttpFoundation\Response

Api

public DateTime|null
# getExpires( )

Returns the value of the Expires header as a DateTime instance.

Returns the value of the Expires header as a DateTime instance.

Returns

DateTime|null
A DateTime instance or null if the header does not exist

Api

public Symfony\Component\HttpFoundation\Response
# setExpires( DateTime $date = null )

Sets the Expires HTTP header with a DateTime instance.

Sets the Expires HTTP header with a DateTime instance.

Passing null as value will remove the header.

Parameters

$date
A \DateTime instance or null to remove the header

Returns

Symfony\Component\HttpFoundation\Response

Api

public integer|null
# getMaxAge( )

Returns the number of seconds after the time specified in the response's Date header when the response should no longer be considered fresh.

Returns the number of seconds after the time specified in the response's Date header when the response should no longer be considered fresh.

First, it checks for a s-maxage directive, then a max-age directive, and then it falls back on an expires header. It returns null when no maximum age can be established.

Returns

integer|null
Number of seconds

Api

public Symfony\Component\HttpFoundation\Response
# setMaxAge( integer $value )

Sets the number of seconds after which the response should no longer be considered fresh.

Sets the number of seconds after which the response should no longer be considered fresh.

This methods sets the Cache-Control max-age directive.

Parameters

$value
Number of seconds

Returns

Symfony\Component\HttpFoundation\Response

Api

public Symfony\Component\HttpFoundation\Response
# setSharedMaxAge( integer $value )

Sets the number of seconds after which the response should no longer be considered fresh by shared caches.

Sets the number of seconds after which the response should no longer be considered fresh by shared caches.

This methods sets the Cache-Control s-maxage directive.

Parameters

$value
Number of seconds

Returns

Symfony\Component\HttpFoundation\Response

Api

public integer|null
# getTtl( )

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

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

It returns null when no freshness information is present in the response.

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

Returns

integer|null
The TTL in seconds

Api

public Symfony\Component\HttpFoundation\Response
# setTtl( 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
Number of seconds

Returns

Symfony\Component\HttpFoundation\Response

Api

public Symfony\Component\HttpFoundation\Response
# setClientTtl( integer $seconds )

Sets the response's time-to-live for private/client caches.

Sets the response's time-to-live for private/client caches.

This method adjusts the Cache-Control/max-age directive.

Parameters

$seconds
Number of seconds

Returns

Symfony\Component\HttpFoundation\Response

Api

public DateTime|null
# getLastModified( )

Returns the Last-Modified HTTP header as a DateTime instance.

Returns the Last-Modified HTTP header as a DateTime instance.

Returns

DateTime|null
A DateTime instance or null if the header does not exist

Throws

RuntimeException
When the HTTP header is not parseable

Api

public Symfony\Component\HttpFoundation\Response
# setLastModified( DateTime $date = null )

Sets the Last-Modified HTTP header with a DateTime instance.

Sets the Last-Modified HTTP header with a DateTime instance.

Passing null as value will remove the header.

Parameters

$date
A \DateTime instance or null to remove the header

Returns

Symfony\Component\HttpFoundation\Response

Api

public string|null
# getEtag( )

Returns the literal value of the ETag HTTP header.

Returns the literal value of the ETag HTTP header.

Returns

string|null
The ETag HTTP header or null if it does not exist

Api

public Symfony\Component\HttpFoundation\Response
# setEtag( string|null $etag = null, boolean $weak = false )

Sets the ETag value.

Sets the ETag value.

Parameters

$etag
The ETag unique identifier or null to remove the header
$weak
Whether you want a weak ETag or not

Returns

Symfony\Component\HttpFoundation\Response

Api

public Symfony\Component\HttpFoundation\Response
# setCache( array $options )

Sets the response's cache headers (validation and/or expiration).

Sets the response's cache headers (validation and/or expiration).

Available options are: etag, last_modified, max_age, s_maxage, private, and public.

Parameters

$options
An array of cache options

Returns

Symfony\Component\HttpFoundation\Response

Throws

InvalidArgumentException

Api

public Symfony\Component\HttpFoundation\Response
# setNotModified( )

Modifies the response so that it conforms to the rules defined for a 304 status code.

Modifies the response so that it conforms to the rules defined for a 304 status code.

This sets the status, removes the body, and discards any headers that MUST NOT be included in 304 responses.

Returns

Symfony\Component\HttpFoundation\Response

See

http://tools.ietf.org/html/rfc2616#section-10.3.5

Api

public boolean
# hasVary( )

Returns true if the response includes a Vary header.

Returns true if the response includes a Vary header.

Returns

boolean
true if the response includes a Vary header, false otherwise

Api

public array
# getVary( )

Returns an array of header names given in the Vary header.

Returns an array of header names given in the Vary header.

Returns

array
An array of Vary names

Api

public Symfony\Component\HttpFoundation\Response
# setVary( string|array $headers, boolean $replace = true )

Sets the Vary header.

Sets the Vary header.

Parameters

$headers
$replace
Whether to replace the actual value of not (true by default)

Returns

Symfony\Component\HttpFoundation\Response

Api

public boolean
# isNotModified( Symfony\Component\HttpFoundation\Request $request )

Determines if the Response validators (ETag, Last-Modified) match a conditional value specified in the Request.

Determines if the Response validators (ETag, Last-Modified) match a conditional value specified in the Request.

If the Response is not modified, it sets the status code to 304 and removes the actual content by calling the setNotModified() method.

Parameters

$request
A Request instance

Returns

boolean
true if the Response validators match the Request, false otherwise

Api

public boolean
# isInvalid( )

Is response invalid?

Is response invalid?

Returns

boolean

Api

public boolean
# isInformational( )

Is response informative?

Is response informative?

Returns

boolean

Api

public boolean
# isSuccessful( )

Is response successful?

Is response successful?

Returns

boolean

Api

public boolean
# isRedirection( )

Is the response a redirect?

Is the response a redirect?

Returns

boolean

Api

public boolean
# isClientError( )

Is there a client error?

Is there a client error?

Returns

boolean

Api

public boolean
# isServerError( )

Was there a server side error?

Was there a server side error?

Returns

boolean

Api

public boolean
# isOk( )

Is the response OK?

Is the response OK?

Returns

boolean

Api

public boolean
# isForbidden( )

Is the response forbidden?

Is the response forbidden?

Returns

boolean

Api

public boolean
# isNotFound( )

Is the response a not found error?

Is the response a not found error?

Returns

boolean

Api

public boolean
# isRedirect( string $location = null )

Is the response a redirect of some form?

Is the response a redirect of some form?

Parameters

$location

Returns

boolean

Api

public boolean
# isEmpty( )

Is the response empty?

Is the response empty?

Returns

boolean

Api

public static
# closeOutputBuffers( integer $targetLevel, boolean $flush )

Cleans or flushes output buffers up to target level.

Cleans or flushes output buffers up to target level.

Resulting level can be greater than target level if a non-removable buffer has been encountered.

Parameters

$targetLevel
The target output buffering level
$flush
Whether to flush or clean the buffers
protected
# ensureIEOverSSLCompatibility( Symfony\Component\HttpFoundation\Request $request )

Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9.

Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9.

Link

http://support.microsoft.com/kb/323308
Constants summary
integer HTTP_CONTINUE
# 100
integer HTTP_SWITCHING_PROTOCOLS
# 101
integer HTTP_PROCESSING
# 102
integer HTTP_OK
# 200
integer HTTP_CREATED
# 201
integer HTTP_ACCEPTED
# 202
integer HTTP_NON_AUTHORITATIVE_INFORMATION
# 203
integer HTTP_NO_CONTENT
# 204
integer HTTP_RESET_CONTENT
# 205
integer HTTP_PARTIAL_CONTENT
# 206
integer HTTP_MULTI_STATUS
# 207
integer HTTP_ALREADY_REPORTED
# 208
integer HTTP_IM_USED
# 226
integer HTTP_MULTIPLE_CHOICES
# 300
integer HTTP_MOVED_PERMANENTLY
# 301
integer HTTP_FOUND
# 302
integer HTTP_SEE_OTHER
# 303
integer HTTP_NOT_MODIFIED
# 304
integer HTTP_USE_PROXY
# 305
integer HTTP_RESERVED
# 306
integer HTTP_TEMPORARY_REDIRECT
# 307
integer HTTP_PERMANENTLY_REDIRECT
# 308
integer HTTP_BAD_REQUEST
# 400
integer HTTP_UNAUTHORIZED
# 401
integer HTTP_PAYMENT_REQUIRED
# 402
integer HTTP_FORBIDDEN
# 403
integer HTTP_NOT_FOUND
# 404
integer HTTP_METHOD_NOT_ALLOWED
# 405
integer HTTP_NOT_ACCEPTABLE
# 406
integer HTTP_PROXY_AUTHENTICATION_REQUIRED
# 407
integer HTTP_REQUEST_TIMEOUT
# 408
integer HTTP_CONFLICT
# 409
integer HTTP_GONE
# 410
integer HTTP_LENGTH_REQUIRED
# 411
integer HTTP_PRECONDITION_FAILED
# 412
integer HTTP_REQUEST_ENTITY_TOO_LARGE
# 413
integer HTTP_REQUEST_URI_TOO_LONG
# 414
integer HTTP_UNSUPPORTED_MEDIA_TYPE
# 415
integer HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
# 416
integer HTTP_EXPECTATION_FAILED
# 417
integer HTTP_I_AM_A_TEAPOT
# 418
integer HTTP_UNPROCESSABLE_ENTITY
# 422
integer HTTP_LOCKED
# 423
integer HTTP_FAILED_DEPENDENCY
# 424
integer HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL
# 425
integer HTTP_UPGRADE_REQUIRED
# 426
integer HTTP_PRECONDITION_REQUIRED
# 428
integer HTTP_TOO_MANY_REQUESTS
# 429
integer HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
# 431
integer HTTP_INTERNAL_SERVER_ERROR
# 500
integer HTTP_NOT_IMPLEMENTED
# 501
integer HTTP_BAD_GATEWAY
# 502
integer HTTP_SERVICE_UNAVAILABLE
# 503
integer HTTP_GATEWAY_TIMEOUT
# 504
integer HTTP_VERSION_NOT_SUPPORTED
# 505
integer HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL
# 506
integer HTTP_INSUFFICIENT_STORAGE
# 507
integer HTTP_LOOP_DETECTED
# 508
integer HTTP_NOT_EXTENDED
# 510
integer HTTP_NETWORK_AUTHENTICATION_REQUIRED
# 511
Properties summary
public Symfony\Component\HttpFoundation\ResponseHeaderBag $headers
#
protected string $content
#
protected string $version
#
protected integer $statusCode
#
protected string $statusText
#
protected string $charset
#
public static array $statusTexts

Status codes translation table.

Status codes translation table.

The list of codes is complete according to the Hypertext Transfer Protocol (HTTP) Status Code Registry (last updated 2012-02-13).

Unless otherwise noted, the status code is defined in RFC2616.

# array( 100 => 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', // RFC2518 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', // RFC4918 208 => 'Already Reported', // RFC5842 226 => 'IM Used', // RFC3229 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Reserved', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', // RFC7238 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', // RFC2324 422 => 'Unprocessable Entity', // RFC4918 423 => 'Locked', // RFC4918 424 => 'Failed Dependency', // RFC4918 425 => 'Reserved for WebDAV advanced collections expired proposal', // RFC2817 426 => 'Upgrade Required', // RFC2817 428 => 'Precondition Required', // RFC6585 429 => 'Too Many Requests', // RFC6585 431 => 'Request Header Fields Too Large', // RFC6585 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates (Experimental)', // RFC2295 507 => 'Insufficient Storage', // RFC4918 508 => 'Loop Detected', // RFC5842 510 => 'Not Extended', // RFC2774 511 => 'Network Authentication Required', // RFC6585 )
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen