mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Detect enabled Brotli compression before Gzip compression
This commit is contained in:
parent
244d4c49c5
commit
2d4ce14b1c
2 changed files with 8 additions and 5 deletions
|
|
@ -4,9 +4,12 @@
|
||||||
|
|
||||||
//header('Strict-Transport-Security: max-age=31536000');
|
//header('Strict-Transport-Security: max-age=31536000');
|
||||||
|
|
||||||
// Uncomment to use gzip encoded output
|
// Uncomment to use gzip compressed output
|
||||||
//define('USE_GZIP', 1);
|
//define('USE_GZIP', 1);
|
||||||
|
|
||||||
|
// Uncomment to use brotli compressed output
|
||||||
|
//define('USE_BROTLI', 1);
|
||||||
|
|
||||||
// Uncomment to enable multiple domain installation.
|
// Uncomment to enable multiple domain installation.
|
||||||
//define('MULTIDOMAIN', 1);
|
//define('MULTIDOMAIN', 1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
|
|
||||||
if (!is_dir(APP_DATA_FOLDER_PATH))
|
if (!is_dir(APP_DATA_FOLDER_PATH))
|
||||||
{
|
{
|
||||||
mkdir(APP_DATA_FOLDER_PATH, 0700);
|
mkdir(APP_DATA_FOLDER_PATH, 0700, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -239,9 +239,7 @@
|
||||||
|
|
||||||
// See https://github.com/kjdev/php-ext-brotli
|
// See https://github.com/kjdev/php-ext-brotli
|
||||||
if (!ini_get('zlib.output_compression') && !ini_get('brotli.output_compression')) {
|
if (!ini_get('zlib.output_compression') && !ini_get('brotli.output_compression')) {
|
||||||
if (defined('USE_GZIP')) {
|
if (defined('USE_BROTLI') && is_callable('brotli_compress_add') && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br')) {
|
||||||
ob_start('ob_gzhandler');
|
|
||||||
} else if (defined('USE_BROTLI') && is_callable('brotli_compress_add') && false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br')) {
|
|
||||||
ob_start(function(string $buffer, int $phase){
|
ob_start(function(string $buffer, int $phase){
|
||||||
static $resource;
|
static $resource;
|
||||||
if ($phase & PHP_OUTPUT_HANDLER_START) {
|
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);
|
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…
Add table
Add a link
Reference in a new issue