本文整理匯總了PHP中CakeResponse::length方法的典型用法代碼示例。如果您正苦於以下問題:PHP CakeResponse::length方法的具體用法?PHP CakeResponse::length怎麽用?PHP CakeResponse::length使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CakeResponse
的用法示例。
在下文中一共展示了CakeResponse::length方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _deliverAsset
/**
* Sends an asset file to the client
*
* @param CakeResponse $response The response object to use.
* @param string $assetFile Path to the asset file in the file system
* @param string $ext The extension of the file to determine its mime type
* @return void
*/
protected function _deliverAsset(CakeResponse $response, $assetFile, $ext)
{
ob_start();
$compressionEnabled = Configure::read('Asset.compress') && $response->compress();
if ($response->type($ext) === $ext) {
$contentType = 'application/octet-stream';
$agent = env('HTTP_USER_AGENT');
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
$contentType = 'application/octetstream';
}
$response->type($contentType);
}
$response->length(false);
$response->cache(filemtime($assetFile));
$response->send();
ob_clean();
if ($ext === 'css' || $ext === 'js') {
include $assetFile;
} else {
readfile($assetFile);
}
if ($compressionEnabled) {
ob_end_flush();
}
}