本文整理汇总了PHP中http::etag方法的典型用法代码示例。如果您正苦于以下问题:PHP http::etag方法的具体用法?PHP http::etag怎么用?PHP http::etag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http
的用法示例。
在下文中一共展示了http::etag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serveDocument
protected static function serveDocument($tpl, $content_type = 'text/html', $http_cache = true, $http_etag = true)
{
$_ctx =& $GLOBALS['_ctx'];
$core =& $GLOBALS['core'];
if ($_ctx->nb_entry_per_page === null) {
$_ctx->nb_entry_per_page = $core->blog->settings->nb_post_per_page;
}
$tpl_file = $core->tpl->getFilePath($tpl);
if (!$tpl_file) {
throw new Exception('Unable to find template');
}
if ($http_cache) {
$GLOBALS['mod_files'][] = $tpl_file;
http::cache($GLOBALS['mod_files'], $GLOBALS['mod_ts']);
}
$result = new ArrayObject();
header('Content-Type: ' . $content_type . '; charset=UTF-8');
$_ctx->current_tpl = $tpl;
$result['content'] = $core->tpl->getData($tpl);
$result['content_type'] = $content_type;
$result['tpl'] = $tpl;
$result['blogupddt'] = $core->blog->upddt;
# --BEHAVIOR-- urlHandlerServeDocument
$core->callBehavior('urlHandlerServeDocument', $result);
if ($http_cache && $http_etag) {
http::etag($result['content'], http::getSelfURI());
}
echo $result['content'];
}
示例2: serveDocument
protected static function serveDocument($tpl, $content_type = 'text/html', $http_cache = true, $http_etag = true)
{
$_ctx =& $GLOBALS['_ctx'];
$core =& $GLOBALS['core'];
if ($_ctx->nb_entry_per_page === null) {
$_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_page;
}
if ($_ctx->nb_entry_first_page === null) {
$_ctx->nb_entry_first_page = $_ctx->nb_entry_per_page;
}
$tpl_file = $core->tpl->getFilePath($tpl);
if (!$tpl_file) {
throw new Exception('Unable to find template ');
}
$result = new ArrayObject();
$_ctx->current_tpl = $tpl;
$_ctx->content_type = $content_type;
$_ctx->http_cache = $http_cache;
$_ctx->http_etag = $http_etag;
$core->callBehavior('urlHandlerBeforeGetData', $_ctx);
if ($_ctx->http_cache) {
$GLOBALS['mod_files'][] = $tpl_file;
http::cache($GLOBALS['mod_files'], $GLOBALS['mod_ts']);
}
header('Content-Type: ' . $_ctx->content_type . '; charset=UTF-8');
if ($core->blog->settings->system->prevents_clickjacking) {
if ($_ctx->exists('xframeoption')) {
$url = parse_url($_ctx->xframeoption);
header(sprintf('X-Frame-Options: %s', is_array($url) ? "ALLOW-FROM " . $url['scheme'] . '://' . $url['host'] : 'SAMEORIGIN'));
} else {
// Prevents Clickjacking as far as possible
header('X-Frame-Options: SAMEORIGIN');
// FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+
}
}
$result['content'] = $core->tpl->getData($_ctx->current_tpl);
$result['content_type'] = $_ctx->content_type;
$result['tpl'] = $_ctx->current_tpl;
$result['blogupddt'] = $core->blog->upddt;
# --BEHAVIOR-- urlHandlerServeDocument
$core->callBehavior('urlHandlerServeDocument', $result);
if ($_ctx->http_cache && $_ctx->http_etag) {
http::etag($result['content'], http::getSelfURI());
}
echo $result['content'];
}