HTTP_CONTINUE
HTTP_CONTINUE = 100
Response represents an HTTP response in JSON format.
Note that this class does not force the returned JSON content to be an object. It is however recommended that you do return an object as it protects yourself against XSSI and JSON-JavaScript Hijacking.
$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.
Example:
return JsonResponse::create($data, 200)
->setSharedMaxAge(300);
mixed | $data | The json response data |
integer | $status | The response status code |
array | $headers | 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.
\Symfony\Component\HttpFoundation\Request | $request |
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.
integer | $code | HTTP status code |
mixed | $text | HTTP status text |
When the HTTP status code is not valid
isCacheable() : boolean
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.
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
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.
\Symfony\Component\HttpFoundation\Request | $request |
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.
integer | $targetLevel | The target output buffering level |
boolean | $flush | Whether to flush or clean the buffers |
ensureIEOverSSLCompatibility(\Symfony\Component\HttpFoundation\Request $request)
Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9.
\Symfony\Component\HttpFoundation\Request | $request |