Class FileResponse
Representation of an HTTP response delivering a file.
- ICanBoogie\HTTP\Response uses ICanBoogie\Accessor\AccessorTrait (not available)
- ┗ ICanBoogie\HTTP\FileResponse
Methods summary
public
__construct( string|SplFileInfo $file
, ICanBoogie\HTTP\Request
$request
, array $options
= [], array $headers
= [] )
public
__invoke( void )
Changes the status to Status::NOT_MODIFIED if the request's Cache-Control has 'no-cache' and is_modified is false.
protected
finalize( ICanBoogie\HTTP\Headers
& $headers
, mixed & $body
)
The following headers are always modified:
protected
finalize_for_not_modified( ICanBoogie\HTTP\Headers
& $headers
)
Finalizes the response for Status::NOT_MODIFIED.
protected
finalize_for_partial_content( ICanBoogie\HTTP\Headers
& $headers
)
Finalizes the response for Status::PARTIAL_CONTENT.
protected
finalize_for_other( ICanBoogie\HTTP\Headers
& $headers
)
Finalizes the response for status other than Status::NOT_MODIFIED or Status::PARTIAL_CONTENT.
protected
get_content_type( void )
: ICanBoogie\HTTP\Headers\ContentType
If the content type returned by the parent is empty the method tries to obtain it from
the file, if it fails ICanBoogie\HTTP\FileResponse::DEFAULT_MIME
is used as fallback.
protected
get_etag( void )
: string
If the etag returned by the parent is empty the method returns a SHA-384 of the file.
protected
get_expires( void )
: ICanBoogie\DateTime|ICanBoogie\HTTP\Headers\Date
If the date returned by the parent is empty the method returns a date created from
ICanBoogie\HTTP\FileResponse::DEFAULT_EXPIRES
.
protected
get_modified_time( void )
: integer
Returns the timestamp at which the file was last modified.
Methods inherited from ICanBoogie\HTTP\Response
__clone()
,
__toString()
,
assert_body_is_valid()
,
get_age()
,
get_body()
,
get_cache_control()
,
get_content_length()
,
get_date()
,
get_is_cacheable()
,
get_is_fresh()
,
get_is_validateable()
,
get_last_modified()
,
get_location()
,
get_status()
,
get_ttl()
,
send_body()
,
send_headers()
,
set_age()
,
set_body()
,
set_cache_control()
,
set_content_length()
,
set_content_type()
,
set_date()
,
set_etag()
,
set_expires()
,
set_last_modified()
,
set_location()
,
set_status()
,
set_ttl()
Constants summary
OPTION_ETAG
: string
Specifies the ETag
header field of the response. If it is not defined the
SHA-384 of the file is used instead.
'etag'
OPTION_EXPIRES
: string
Specifies the expiration date as a ICanBoogie\DateTime instance or a relative date
such as "+3 month", which maps to the Expires
header field. The max-age
directive of
the Cache-Control
header field is computed from the current time. If it is not
defined ICanBoogie\HTTP\FileResponse::DEFAULT_EXPIRES
is used instead.
'expires'
OPTION_FILENAME
: string
Specifies the filename of the file and forces download. The following header are updated:
Content-Transfer-Encoding
, Content-Description
, and Content-Dispositon
.
'filename'
Properties summary
Properties inherited from ICanBoogie\HTTP\Response
Magic properties
Magic properties inherited from ICanBoogie\HTTP\Response
$age
,
$body
,
$cache_control
,
$content_length
,
$content_type
,
$date
,
$etag
,
$expires
,
$is_cacheable
,
$is_fresh
,
$is_private
,
$is_validateable
,
$last_modified
,
$location
,
$status
,
$ttl