File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace Utopia ;
44
5+ use Utopia \CLI \Console ;
56use Utopia \Compression \Compression ;
67
78class 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 }
You can’t perform that action at this time.
0 commit comments