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