HTTP_CONTINUE
HTTP_CONTINUE
BinaryFileResponse represents an HTTP response delivering a file.
$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 2012-02-13).
Unless otherwise noted, the status code is defined in RFC2616.
__construct(\SplFileInfo|string $file, integer $status = 200, array $headers = array(), boolean $public = true, null|string $contentDisposition = null, boolean $autoEtag = false, boolean $autoLastModified = true)
Constructor.
| \SplFileInfo|string | $file | The file to stream |
| integer | $status | The response status code |
| array | $headers | An array of response headers |
| boolean | $public | Files are public by default |
| null|string | $contentDisposition | The type of Content-Disposition to set automatically with the filename |
| boolean | $autoEtag | Whether the ETag header should be automatically set |
| boolean | $autoLastModified | Whether the Last-Modified header should be automatically set |
create(\SplFileInfo|string $file = null, integer $status = 200, array $headers = array(), boolean $public = true, null|string $contentDisposition = null, boolean $autoEtag = false, boolean $autoLastModified = true) : \Symfony\Component\HttpFoundation\BinaryFileResponse
Factory method for chainability.
Example:
return Response::create($body, 200)
->setSharedMaxAge(300);
| \SplFileInfo|string | $file | The file to stream |
| integer | $status | The response status code |
| array | $headers | An array of response headers |
| boolean | $public | Files are public by default |
| null|string | $contentDisposition | The type of Content-Disposition to set automatically with the filename |
| boolean | $autoEtag | Whether the ETag header should be automatically set |
| boolean | $autoLastModified | Whether the Last-Modified header should be automatically set |
The created response
prepare(\Symfony\Component\HttpFoundation\Request $request) : \Symfony\Component\HttpFoundation\Response
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 | A Request instance |
The current response.
sendHeaders() : \Symfony\Component\HttpFoundation\Response
Sends HTTP headers.
sendContent() : \Symfony\Component\HttpFoundation\Response
Sends the file.
send() : \Symfony\Component\HttpFoundation\Response
Sends HTTP headers and content.
setContent(mixed $content) : \Symfony\Component\HttpFoundation\Response
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
setProtocolVersion(string $version) : \Symfony\Component\HttpFoundation\Response
Sets the HTTP protocol version (1.0 or 1.1).
| string | $version | The HTTP protocol version |
setStatusCode(integer $code, mixed $text = null) : \Symfony\Component\HttpFoundation\Response
Sets the response status code.
| integer | $code | HTTP status code |
| mixed | $text | HTTP status text If the status text is null it will be automatically populated for the known status codes and left empty otherwise. |
When the HTTP status code is not valid
setCharset(string $charset) : \Symfony\Component\HttpFoundation\Response
Sets the response charset.
| string | $charset | Character set |
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
setPrivate() : \Symfony\Component\HttpFoundation\Response
Marks the response as "private".
It makes the response ineligible for serving other clients.
setPublic() : \Symfony\Component\HttpFoundation\Response
Marks the response as "public".
It makes the response eligible for serving other clients.
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
setDate(\DateTime $date) : \Symfony\Component\HttpFoundation\Response
Sets the Date header.
| \DateTime | $date | A \DateTime instance |
expire() : \Symfony\Component\HttpFoundation\Response
Marks the response stale by setting the Age header to be equal to the maximum age of the response.
setExpires(\DateTime|null $date = null) : \Symfony\Component\HttpFoundation\Response
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 |
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
setMaxAge(integer $value) : \Symfony\Component\HttpFoundation\Response
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 |
setSharedMaxAge(integer $value) : \Symfony\Component\HttpFoundation\Response
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 |
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
setTtl(integer $seconds) : \Symfony\Component\HttpFoundation\Response
Sets the response's time-to-live for shared caches.
This method adjusts the Cache-Control/s-maxage directive.
| integer | $seconds | Number of seconds |
setClientTtl(integer $seconds) : \Symfony\Component\HttpFoundation\Response
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 |
setLastModified(\DateTime|null $date = null) : \Symfony\Component\HttpFoundation\Response
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 |
setEtag(string|null $etag = null, boolean $weak = false) : \Symfony\Component\HttpFoundation\Response
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 |
setCache(array $options) : \Symfony\Component\HttpFoundation\Response
Sets the response's cache headers (validation and/or expiration).
Available options are: etag, last_modified, max_age, s_maxage, private, and public.
| array | $options | An array of cache options |
setNotModified() : \Symfony\Component\HttpFoundation\Response
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.
setVary(string|array $headers, boolean $replace = true) : \Symfony\Component\HttpFoundation\Response
Sets the Vary header.
| string|array | $headers | |
| boolean | $replace | Whether to replace the actual value of not (true by default) |
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 | A Request instance |
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 |
setFile(\SplFileInfo|string $file, string $contentDisposition = null, boolean $autoEtag = false, boolean $autoLastModified = true) : \Symfony\Component\HttpFoundation\BinaryFileResponse
Sets the file to stream.
| \SplFileInfo|string | $file | The file to stream |
| string | $contentDisposition | |
| boolean | $autoEtag | |
| boolean | $autoLastModified |
getFile() : \Symfony\Component\HttpFoundation\File\File
Gets the file.
The file to stream
setContentDisposition(string $disposition, string $filename = '', string $filenameFallback = '') : \Symfony\Component\HttpFoundation\BinaryFileResponse
Sets the Content-Disposition header with the given filename.
| string | $disposition | ResponseHeaderBag::DISPOSITION_INLINE or ResponseHeaderBag::DISPOSITION_ATTACHMENT |
| string | $filename | Optionally use this filename instead of the real name of the file |
| string | $filenameFallback | A fallback filename, containing only ASCII characters. Defaults to an automatically encoded filename |
deleteFileAfterSend(boolean $shouldDelete) : \Symfony\Component\HttpFoundation\BinaryFileResponse
If this is set to true, the file will be unlinked after the request is send Note: If the X-Sendfile header is used, the deleteFileAfterSend setting will not be used.
| boolean | $shouldDelete |
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 |