‪TYPO3CMS  9.5
CompressionUtility.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
24 {
32  protected ‪$contentLength = 0;
33 
44  public function ‪compressionOutputHandler($outputBuffer, $mode)
45  {
46  // Compress the content
47  $outputBuffer = ob_gzhandler($outputBuffer, $mode);
48  if ($outputBuffer !== false) {
49  // Save compressed size
50  $this->contentLength += strlen($outputBuffer);
51  // Check if this was the last content chunk
52  if (0 != ($mode & PHP_OUTPUT_HANDLER_END)) {
53  // Check if we have content-length header
54  foreach (headers_list() as $header) {
55  if (0 == strncasecmp('Content-length:', $header, 15)) {
56  header('Content-length: ' . $this->contentLength);
57  break;
58  }
59  }
60  }
61  }
62  return $outputBuffer;
63  }
64 }
‪TYPO3\CMS\Frontend\Utility\CompressionUtility
Definition: CompressionUtility.php:24
‪TYPO3\CMS\Frontend\Utility
Definition: CanonicalizationUtility.php:4
‪TYPO3\CMS\Frontend\Utility\CompressionUtility\$contentLength
‪int $contentLength
Definition: CompressionUtility.php:31
‪TYPO3\CMS\Frontend\Utility\CompressionUtility\compressionOutputHandler
‪string compressionOutputHandler($outputBuffer, $mode)
Definition: CompressionUtility.php:43
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22