mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-09-20 07:35:55 +08:00
Detect enabled Brotli compression before Gzip compression
This commit is contained in:
parent
244d4c49c5
commit
2d4ce14b1c
|
@ -4,9 +4,12 @@
|
|||
|
||||
//header('Strict-Transport-Security: max-age=31536000');
|
||||
|
||||
// Uncomment to use gzip encoded output
|
||||
// Uncomment to use gzip compressed output
|
||||
//define('USE_GZIP', 1);
|
||||
|
||||
// Uncomment to use brotli compressed output
|
||||
//define('USE_BROTLI', 1);
|
||||
|
||||
// Uncomment to enable multiple domain installation.
|
||||
//define('MULTIDOMAIN', 1);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
|
||||
if (!is_dir(APP_DATA_FOLDER_PATH))
|
||||
{
|
||||
mkdir(APP_DATA_FOLDER_PATH, 0700);
|
||||
mkdir(APP_DATA_FOLDER_PATH, 0700, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -239,9 +239,7 @@
|
|||
|
||||
// See https://github.com/kjdev/php-ext-brotli
|
||||
if (!ini_get('zlib.output_compression') && !ini_get('brotli.output_compression')) {
|
||||
if (defined('USE_GZIP')) {
|
||||
ob_start('ob_gzhandler');
|
||||
} else if (defined('USE_BROTLI') && is_callable('brotli_compress_add') && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br')) {
|
||||
if (defined('USE_BROTLI') && is_callable('brotli_compress_add') && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br')) {
|
||||
ob_start(function(string $buffer, int $phase){
|
||||
static $resource;
|
||||
if ($phase & PHP_OUTPUT_HANDLER_START) {
|
||||
|
@ -250,6 +248,8 @@
|
|||
}
|
||||
return brotli_compress_add($resource, $buffer, ($phase & PHP_OUTPUT_HANDLER_FINAL) ? BROTLI_FINISH : BROTLI_PROCESS);
|
||||
});
|
||||
} else if (defined('USE_GZIP')) {
|
||||
ob_start('ob_gzhandler');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue