HTTP_CONTINUE
HTTP_CONTINUE = 100
StreamedResponse represents a streamed HTTP response.
A StreamedResponse uses a callback for its content.
The callback should use the standard PHP functions like echo to stream the response back to the client. The flush() method can also be used if needed.
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
None found |
$headers : \Symfony\Component\HttpFoundation\ResponseHeaderBag
None found |
$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.
None found |
None found |
None found |
None found |
None found |
None found |
__construct(callable|null $callback = null, integer $status = 200, array $headers = array())
callable|null | $callback | A valid PHP callback or null to set it later |
integer | $status | The response status code |
array | $headers | An array of response headers |
None found |
create(callable|null $callback = null, integer $status = 200, array $headers = array()) : static
Factory method for chainability.
Example:
return Response::create($body, 200)
->setSharedMaxAge(300);
callable|null | $callback | A valid PHP callback or null to set it later |
integer | $status | The response status code |
array | $headers | An array of response headers |
None found |
__toString() : 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.
The Response as an HTTP string
None found |
None found |
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 |
None found |
sendHeaders() : $this
Sends HTTP headers.
This method only sends the headers once.
None found |
sendContent() : $this
Sends content for the current web response.
This method only sends the content once.
None found |
None found |
setContent(mixed $content) : $this
Sets the response content.
Valid types are strings, numbers, null, and objects that implement a __toString() method.
mixed | $content | Content that can be cast to string |
when the content is not null
None found |
None found |
setProtocolVersion(string $version) : $this
Sets the HTTP protocol version (1.0 or 1.1).
string | $version | The HTTP protocol version |
final |
since version 3.2 |
---|
getProtocolVersion() : string
Gets the HTTP protocol version.
The HTTP protocol version
final |
since version 3.2 |
---|
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
final |
since version 3.2 |
---|
getStatusCode() : integer
Retrieves the status code for the current web response.
Status code
final |
since version 3.2 |
---|
setCharset(string $charset) : $this
Sets the response charset.
string | $charset | Character set |
final |
since version 3.2 |
---|
final |
since version 3.2 |
---|
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
final |
since version 3.3 |
---|
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
final |
since version 3.3 |
---|
isValidateable() : boolean
Returns true if the response includes headers that can be used to validate the response with the origin server using a conditional GET request.
true if the response is validateable, false otherwise
final |
since version 3.3 |
---|
setPrivate() : $this
Marks the response as "private".
It makes the response ineligible for serving other clients.
final |
since version 3.2 |
---|
setPublic() : $this
Marks the response as "public".
It makes the response eligible for serving other clients.
final |
since version 3.2 |
---|
setImmutable(boolean $immutable = true) : $this
Marks the response as "immutable".
boolean | $immutable | enables or disables the immutable directive |
final |
---|
isImmutable() : boolean
Returns true if the response is marked as "immutable".
returns true if the response is marked as "immutable"; otherwise false
final |
---|
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
final |
since version 3.3 |
---|
getDate() : \DateTime
Returns the Date header as a DateTime instance.
When the header is not parseable
A \DateTime instance
final |
since version 3.2 |
---|
setDate(\DateTime $date) : $this
Sets the Date header.
\DateTime | $date |
final |
since version 3.2 |
---|
getAge() : integer
Returns the age of the response.
The age of the response in seconds
final |
since version 3.2 |
---|
expire() : $this
Marks the response stale by setting the Age header to be equal to the maximum age of the response.
None found |
getExpires() : \DateTime|null
Returns the value of the Expires header as a DateTime instance.
A DateTime instance or null if the header does not exist
final |
since version 3.2 |
---|
setExpires(\DateTime|null $date = null) : $this
Sets the Expires HTTP header with a DateTime instance.
Passing null as value will remove the header.
\DateTime|null | $date | A \DateTime instance or null to remove the header |
final |
since version 3.2 |
---|
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
final |
since version 3.2 |
---|
setMaxAge(integer $value) : $this
Sets the number of seconds after which the response should no longer be considered fresh.
This methods sets the Cache-Control max-age directive.
integer | $value | Number of seconds |
final |
since version 3.2 |
---|
setSharedMaxAge(integer $value) : $this
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.
integer | $value | Number of seconds |
final |
since version 3.2 |
---|
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
final |
since version 3.2 |
---|
setTtl(integer $seconds) : $this
Sets the response's time-to-live for shared caches.
This method adjusts the Cache-Control/s-maxage directive.
integer | $seconds | Number of seconds |
final |
since version 3.2 |
---|
setClientTtl(integer $seconds) : $this
Sets the response's time-to-live for private/client caches.
This method adjusts the Cache-Control/max-age directive.
integer | $seconds | Number of seconds |
final |
since version 3.2 |
---|
getLastModified() : \DateTime|null
Returns the Last-Modified HTTP header as a DateTime instance.
When the HTTP header is not parseable
A DateTime instance or null if the header does not exist
final |
since version 3.2 |
---|
setLastModified(\DateTime|null $date = null) : $this
Sets the Last-Modified HTTP header with a DateTime instance.
Passing null as value will remove the header.
\DateTime|null | $date | A \DateTime instance or null to remove the header |
final |
since version 3.2 |
---|
getEtag() : string|null
Returns the literal value of the ETag HTTP header.
The ETag HTTP header or null if it does not exist
final |
since version 3.2 |
---|
setEtag(string|null $etag = null, boolean $weak = false) : $this
Sets the ETag value.
string|null | $etag | The ETag unique identifier or null to remove the header |
boolean | $weak | Whether you want a weak ETag or not |
final |
since version 3.2 |
---|
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.
array | $options | An array of cache options |
final |
since version 3.3 |
---|
setNotModified() : $this
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.
None found |
hasVary() : boolean
Returns true if the response includes a Vary header.
true if the response includes a Vary header, false otherwise
final |
since version 3.2 |
---|
getVary() : array
Returns an array of header names given in the Vary header.
An array of Vary names
final |
since version 3.2 |
---|
setVary(string|array $headers, boolean $replace = true) : $this
Sets the Vary header.
string|array | $headers | |
boolean | $replace | Whether to replace the actual value or not (true by default) |
final |
since version 3.2 |
---|
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
final |
since version 3.3 |
---|
final |
since version 3.2 |
---|
final |
since version 3.3 |
---|
final |
since version 3.2 |
---|
final |
since version 3.2 |
---|
final |
since version 3.2 |
---|
final |
since version 3.3 |
---|
final |
since version 3.2 |
---|
final |
since version 3.2 |
---|
final |
since version 3.2 |
---|
isRedirect(string $location = null) : boolean
Is the response a redirect of some form?
string | $location |
final |
since version 3.2 |
---|
final |
since version 3.2 |
---|
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 |
final |
since version 3.3 |
---|
setCallback(callable $callback) : $this
Sets the PHP callback associated with this Response.
callable | $callback | A valid PHP callback |
None found |
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 |
final |
since version 3.3 |
---|