From 2c9eb73566d652ca9ec15c2b5a03b06765c4e56c Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 21 Jan 2023 23:02:34 +0100 Subject: [PATCH] Fix --- src/danog/MadelineProto/Connection.php | 20 +++++-------------- .../MadelineProto/MTProtoTools/Files.php | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) 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");