本文整理汇总了PHP中HTTP_Encoder::sendAll方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP_Encoder::sendAll方法的具体用法?PHP HTTP_Encoder::sendAll怎么用?PHP HTTP_Encoder::sendAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTP_Encoder
的用法示例。
在下文中一共展示了HTTP_Encoder::sendAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Gzip (encode) the HTTP response and write to output.
* @param string $strBody The content that should be in the response.
* @param string $strContentType The MIME type of the content.
*/
public static function send($strBody, $strContentType = "text/html")
{
$objEncoder = new \HTTP_Encoder(array("content" => $strBody, "type" => $strContentType));
$objEncoder->encode();
$objEncoder->sendAll();
exit;
}
示例2: render
public static function render($arrFilter)
{
$dtLastModified = 0;
//*** Load sources from sources directory.
if (is_dir($GLOBALS["_PATHS"]['css'])) {
//*** Directory exists.
foreach ($arrFilter as $strFilter) {
$strFile = $GLOBALS["_PATHS"]['css'] . "{$strFilter}.css";
$dtLastModified = self::getLastModified($strFile, $dtLastModified);
//*** Auto check custom files.
if (strpos($strFilter, "-custom") === false) {
$strFile = $GLOBALS["_PATHS"]['css'] . "{$strFilter}-custom.css";
$dtLastModified = self::getLastModified($strFile, $dtLastModified);
}
}
}
//*** Check if we can send a "Not Modified" header.
\HTTP_ConditionalGet::check($dtLastModified, true, array("maxAge" => 1200000));
//*** Modified. Get contents.
$strOutput = self::minify($arrFilter);
//*** Gzip the CSS.
$objEncoder = new \HTTP_Encoder(array("content" => $strOutput, "type" => "text/css"));
$objEncoder->encode();
$objEncoder->sendAll();
}
示例3: render
public static function render($arrFilter)
{
$dtLastModified = 0;
//*** Load sources from sources directory.
if (is_dir($GLOBALS["_PATHS"]['js'])) {
//*** Directory exists.
foreach ($arrFilter as $strFilter) {
$strFile = $GLOBALS["_PATHS"]['js'] . $strFilter . ".js";
if (is_file($strFile)) {
$lngLastModified = filemtime($strFile);
if (empty($dtLastModified) || $lngLastModified > $dtLastModified) {
$dtLastModified = $lngLastModified;
}
}
}
}
//*** Check if we can send a "Not Modified" header.
\HTTP_ConditionalGet::check($dtLastModified, true, array("maxAge" => 1200000));
//*** Modified. Get contents.
$strOutput = self::minify($arrFilter);
//*** Gzip the Javascript.
$objEncoder = new \HTTP_Encoder(array("content" => $strOutput, "type" => "text/javascript"));
$objEncoder->encode();
$objEncoder->sendAll();
}
示例4: output
/**
* Encode and send appropriate headers and content
*
* This is a convenience method for common use of the class
*
* @param string $content
*
* @param int $compressionLevel given to zlib functions. If not given, the
* class default will be used.
*
* @return bool success true if the content was actually compressed
*/
public static function output($content, $compressionLevel = null)
{
if (null === $compressionLevel) {
$compressionLevel = self::$compressionLevel;
}
$he = new HTTP_Encoder(array('content' => $content));
$ret = $he->encode($compressionLevel);
$he->sendAll();
return $ret;
}
示例5: header
<?php
/**
* AJAX checks for zlib.output_compression
*
* @package Minify
*/
$_oc = ini_get('zlib.output_compression');
// allow access only if builder is enabled
require __DIR__ . '/../config.php';
if (!$min_enableBuilder) {
header('Location: /');
exit;
}
if (isset($_GET['hello'])) {
// echo 'World!'
// try to prevent double encoding (may not have an effect)
ini_set('zlib.output_compression', '0');
require $min_libPath . '/HTTP/Encoder.php';
HTTP_Encoder::$encodeToIe6 = true;
// just in case
$he = new HTTP_Encoder(array('content' => 'World!', 'method' => 'deflate'));
$he->encode();
$he->sendAll();
} else {
// echo status "0" or "1"
header('Content-Type: text/plain');
echo (int) $_oc;
}
示例6: _echo_javascript
/**
* Echoes the Javascript if not cached.
*
* Echoes the javascript with the correct content.
* Since the content is dinamic, i use the hash function.
*
* @param string $javascript
*
* @return void
*/
private function _echo_javascript($javascript)
{
$conditional_get = new HTTP_ConditionalGet(array('contentHash' => md5($javascript)));
$conditional_get->sendHeaders();
if (!$conditional_get->cacheIsValid) {
$http_encoder = new HTTP_Encoder(array('content' => $javascript, 'type' => 'text/javascript'));
$compression_level = null;
if ($this->_registry->get('model.settings')->get('disable_gzip_compression')) {
// set the compression level to 0 to disable it.
$compression_level = 0;
}
$http_encoder->encode($compression_level);
$http_encoder->sendAll();
}
Ai1ec_Http_Response_Helper::stop(0);
}