TYPO3 CMS  TYPO3_6-2
CompressionUtility.php
Go to the documentation of this file.
1 <?php
3 
23 
31  protected $contentLength = 0;
32 
44  public function compressionOutputHandler($outputBuffer, $mode) {
45  // Compress the content
46  $outputBuffer = ob_gzhandler($outputBuffer, $mode);
47  if ($outputBuffer !== FALSE) {
48  // Save compressed size
49  $this->contentLength += strlen($outputBuffer);
50  // Check if this was the last content chunk
51  if (0 != ($mode & PHP_OUTPUT_HANDLER_END)) {
52  // Check if we have content-length header
53  foreach (headers_list() as $header) {
54  if (0 == strncasecmp('Content-length:', $header, 15)) {
55  header('Content-length: ' . $this->contentLength);
56  break;
57  }
58  }
59  }
60  }
61  return $outputBuffer;
62  }
63 
64 }