diff --git a/src/danog/MadelineProto/Connection.php b/src/danog/MadelineProto/Connection.php index c23d35003..434ac9643 100644 --- a/src/danog/MadelineProto/Connection.php +++ b/src/danog/MadelineProto/Connection.php @@ -264,21 +264,11 @@ final class Connection } $this->httpReqCount = 0; $this->httpResCount = 0; - if (!isset($this->writer)) { - $this->writer = new WriteLoop($this); - } - if (!isset($this->reader)) { - $this->reader = new ReadLoop($this); - } - if (!isset($this->checker)) { - $this->checker = new CheckLoop($this); - } - if (!isset($this->cleanup)) { - $this->cleanup = new CleanupLoop($this); - } - if (!isset($this->waiter)) { - $this->waiter = new HttpWaitLoop($this); - } + $this->writer ??= new WriteLoop($this); + $this->reader ??= new ReadLoop($this); + $this->checker ??= new CheckLoop($this); + $this->cleanup ??= new CleanupLoop($this); + $this->waiter ??= new HttpWaitLoop($this); if (!isset($this->pinger) && !$this->ctx->isMedia() && !$this->ctx->isCDN()) { $this->pinger = new PingLoop($this); } diff --git a/src/danog/MadelineProto/MTProtoTools/Files.php b/src/danog/MadelineProto/MTProtoTools/Files.php index 3ca3b9e04..c3111c442 100644 --- a/src/danog/MadelineProto/MTProtoTools/Files.php +++ b/src/danog/MadelineProto/MTProtoTools/Files.php @@ -80,7 +80,7 @@ trait Files throw new Exception("Wrong status code: {$status} ".$response->getReason()); } $mime = \trim(\explode(';', $response->getHeader('content-type') ?? 'application/octet-stream')[0]); - $size = $response->getHeader('content-length') ?? $size; + $size = (int) ($response->getHeader('content-length') ?? $size); $stream = $response->getBody(); if (!$size) { $this->logger->logger("No content length for {$url}, caching first");