HTTP_CONTINUE = 100
Response represents an HTTP response in JSON format.
$headers : \Symfony\Component\HttpFoundation\ResponseHeaderBag
$statusTexts : array
Status codes translation table.
The list of codes is complete according to the Hypertext Transfer Protocol (HTTP) Status Code Registry (last updated 2016-03-01).
Unless otherwise noted, the status code is defined in RFC2616.
create(mixed $data = null, integer $status = 200, array $headers = array()) : static
Factory method for chainability.
return JsonResponse::create($data, 200) ->setSharedMaxAge(300);
The json response data
The response status code
An array of response headers
prepare(\Symfony\Component\HttpFoundation\Request $request) : $this
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.
setStatusCode(integer $code, mixed $text = null) : $this
Sets the response status code.
If the status text is null it will be automatically populated for the known status codes and left empty otherwise.
HTTP status code
HTTP status text
When the HTTP status code is not valid
isCacheable() : boolean
Returns true if the response may safely be kept in a shared (surrogate) cache.
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 because there is no way to tell when or how to remove them from the cache.
Note that RFC 7231 and RFC 7234 possibly allow for a more permissive implementation, for example "status codes that are defined as cacheable by default [...] can be reused by a cache with heuristic expiration unless otherwise indicated" (https://tools.ietf.org/html/rfc7231#section-6.1)
true if the response is worth caching, false otherwise
isFresh() : boolean
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.
true if the response is fresh, false otherwise
mustRevalidate() : boolean
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.
true if the response must be revalidated by a cache, false otherwise
getMaxAge() : integer|null
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.
Number of seconds
getTtl() : integer|null
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.
The TTL in seconds
setCache(array $options) : $this
Sets the response's cache headers (validation and/or expiration).
Available options are: etag, last_modified, max_age, s_maxage, private, public and immutable.
An array of cache options
isNotModified(\Symfony\Component\HttpFoundation\Request $request) : boolean
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.
true if the Response validators match the Request, false otherwise
closeOutputBuffers(integer $targetLevel, boolean $flush)
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.
The target output buffering level
Whether to flush or clean the buffers
Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9.