Skip to content

Commit 72239fb

Browse files
committed
debug: compression
1 parent a501a56 commit 72239fb

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/Response.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Utopia;
44

5+
use Utopia\CLI\Console;
56
use Utopia\Compression\Compression;
67

78
class Response
@@ -315,7 +316,7 @@ public function setCompressionMinSize(int $compressionMinSize): static
315316

316317
/**
317318
* Set supported compression algorithms
318-
*
319+
*
319320
* @param mixed $compressionSupported
320321
*/
321322
public function setCompressionSupported(mixed $compressionSupported): static
@@ -540,15 +541,26 @@ public function send(string $body = ''): void
540541
}
541542

542543
// Compress body
544+
Console::log('Accept-Encoding: '.$this->acceptEncoding . ' - ' . $this->compressionMinSize);
545+
Console::log('Content-Type: '.$this->contentType . ' - ' . $this->compressed[$this->contentType]);
546+
Console::log('Content-Length: '.strlen($body) . ' - ' . $this->compressionMinSize);
547+
543548
if (
544549
!empty($this->acceptEncoding) &&
545550
isset($this->compressed[$this->contentType]) &&
546551
strlen($body) > $this->compressionMinSize
547552
) {
548553
$algorithm = Compression::fromAcceptEncoding($this->acceptEncoding, $this->compressionSupported);
549554

555+
Console::log('Compression Algorithm: '.($algorithm ? $algorithm->getName() : 'none'));
556+
550557
if ($algorithm) {
558+
Console::log('Body before compression: '.strlen($body));
559+
551560
$body = $algorithm->compress($body);
561+
562+
Console::log('Body after compression: '.strlen($body));
563+
552564
$this->addHeader('Content-Encoding', $algorithm->getContentEncoding());
553565
$this->addHeader('Vary', 'Accept-Encoding');
554566
}

0 commit comments

Comments
 (0)