本文整理汇总了PHP中HTTP_Encoder::sendHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP_Encoder::sendHeaders方法的具体用法?PHP HTTP_Encoder::sendHeaders怎么用?PHP HTTP_Encoder::sendHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTP_Encoder
的用法示例。
在下文中一共展示了HTTP_Encoder::sendHeaders方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendHeaders
/**
* Overrides parent function and removed Content-Length header to avoid
* some problems if our JavaScript is somehow prepended by 3rd party code.
*
* @return void Method does not return.
*/
public function sendHeaders()
{
unset($this->_headers['Content-Length']);
parent::sendHeaders();
}
示例2: round
<?php
require __DIR__ . '/../../bootstrap.php';
// emulate regularly updating document
$every = 20;
$lastModified = round(time() / $every) * $every - $every;
list($enc, ) = HTTP_Encoder::getAcceptedEncoding();
$cg = new HTTP_ConditionalGet(array('lastModifiedTime' => $lastModified, 'encoding' => $enc));
$cg->sendHeaders();
if ($cg->cacheIsValid) {
// we're done
exit;
}
// output encoded content
$title = 'ConditionalGet + Encoder';
$explain = '
<p>Using ConditionalGet and Encoder is straightforward. First impliment the
ConditionalGet, then if the cache is not valid, encode and send the content</p>
<p>This script emulates a document that changes every ' . $every . ' seconds.
<br>This is version: ' . date('r', $lastModified) . '</p>
';
require '_include.php';
$content = get_content(array('title' => $title, 'explain' => $explain));
$he = new HTTP_Encoder(array('content' => get_content(array('title' => $title, 'explain' => $explain))));
$he->encode();
// usually you would just $he->sendAll(), but here we want to emulate slow
// connection
$he->sendHeaders();
send_slowly($he->getContent());