Added option to change gzip compression threshold or disable it altogether
This commit is contained in:
parent
de26dc37ab
commit
cab1bececc
@ -46,7 +46,7 @@ class MTProto
|
||||
/*
|
||||
const V = 71;
|
||||
*/
|
||||
const V = 73;
|
||||
const V = 74;
|
||||
|
||||
const NOT_LOGGED_IN = 0;
|
||||
const WAITING_CODE = 1;
|
||||
@ -580,6 +580,9 @@ class MTProto
|
||||
'peer' => [
|
||||
'full_info_cache_time' => 60,
|
||||
],
|
||||
'requests' => [
|
||||
'gzip_encode_if_gt' => 500 // Should I try using gzip encoding for requests bigger than N bytes? Set to -1 to disable.
|
||||
],
|
||||
'updates' => [
|
||||
'handle_updates' => true, // Should I handle updates?
|
||||
'callback' => 'get_updates_update_handler', // A callable function that will be called every time an update is received, must accept an array (for the update) as the only parameter
|
||||
|
@ -74,7 +74,7 @@ trait CallHandler
|
||||
if (isset($queue)) {
|
||||
$serialized = $this->serialize_method('invokeAfterMsgs', ['msg_ids' => $this->datacenter->sockets[$aargs['datacenter']]->call_queue[$queue], 'query' => $serialized]);
|
||||
}
|
||||
if (($l = strlen($serialized)) > 500 && ($g = strlen($gzipped = gzencode($serialized))) < $l) {
|
||||
if ($this->settings['requests']['gzip_encode_if_gt'] !== -1 && ($l = strlen($serialized)) > $this->settings['requests']['gzip_encode_if_gt'] && ($g = strlen($gzipped = gzencode($serialized))) < $l) {
|
||||
$serialized = $this->serialize_object(['type' => 'gzip_packed'], ['packed_data' => $gzipped], 'gzipped data');
|
||||
\danog\MadelineProto\Logger::log(['Using GZIP compression for '.$method.', saved '.($l - $g).' bytes of data, reduced call size by '.($g * 100 / $l).'%'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user