本文整理汇总了PHP中Cake\Network\Response::sendHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::sendHeaders方法的具体用法?PHP Response::sendHeaders怎么用?PHP Response::sendHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Network\Response
的用法示例。
在下文中一共展示了Response::sendHeaders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterResponse
/**
* Filters the cake response to the BrowserKit one.
*
* @param \Cake\Network\Response $response Cake response.
* @return \Symfony\Component\BrowserKit\Response BrowserKit response.
*/
protected function filterResponse($response)
{
$this->cake['response'] = $response;
foreach ($response->cookie() as $cookie) {
$this->getCookieJar()->set(new Cookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httpOnly']));
}
$response->sendHeaders();
return new BrowserKitResponse($response->body(), $response->statusCode(), $response->header());
}
示例2: _deliverAsset
/**
* Sends an asset file to the client
*
* @param \Cake\Network\Request $request The request object to use.
* @param \Cake\Network\Response $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(Request $request, Response $response, $assetFile, $ext)
{
$compressionEnabled = $response->compress();
if ($response->type($ext) === $ext) {
$contentType = 'application/octet-stream';
$agent = $request->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);
}
if (!$compressionEnabled) {
$response->header('Content-Length', filesize($assetFile));
}
// $response->cache(filemtime($assetFile), $this->_cacheTime);
$response->sendHeaders();
readfile($assetFile);
if ($compressionEnabled) {
ob_end_flush();
}
}