From f4c1a5ea35dd942de9b39c6c367be40a8484fdb2 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 7 Aug 2022 14:01:00 +0300 Subject: [PATCH] response::send --- app/controllers/api/storage.php | 1 - app/controllers/shared/api.php | 1 + src/Appwrite/Utopia/Response.php | 39 +------------------------------- 3 files changed, 2 insertions(+), 39 deletions(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 2bb5dde3b1..7e62245c4f 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -878,7 +878,6 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/preview') $algorithm = $file->getAttribute('algorithm'); $cipher = $file->getAttribute('openSSLCipher'); $mime = $file->getAttribute('mimeType'); - if (!\in_array($mime, $inputs) || $file->getAttribute('sizeActual') > (int) App::getEnv('_APP_STORAGE_PREVIEW_LIMIT', 20000000)) { if (!\in_array($mime, $inputs)) { $path = (\array_key_exists($mime, $fileLogos)) ? $fileLogos[$mime] : $fileLogos['default']; diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index e85d813250..b9e50c6873 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -121,6 +121,7 @@ App::init(function (App $utopia, Request $request, Response $response, Document $cache = new Cache(new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId())); $timestamp = 60 * 60 * 24 * 30; $data = $cache->load($key, $timestamp); + var_dump(!empty($data)); if (!empty($data)) { $cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key)); if ($cacheLog->isEmpty()) { diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 8b0b313edb..8aa97fd8c6 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -457,52 +457,15 @@ class Response extends SwooleResponse */ public function send(string $body = ''): void { - if ($this->sent) { - return; - } - - $this->sent = true; - - $this->addHeader('X-Debug-Speed', (string)(\microtime(true) - $this->startTime)); - $this->payload = [ 'content-type' => $this->getContentType(), 'payload' => $body ]; - $this - ->appendCookies() - ->appendHeaders() - ; - - if (!$this->disablePayload) { - $length = strlen($body); - - $this->size = $this->size + strlen(implode("\n", $this->headers)) + $length; - - if ( - array_key_exists( - $this->contentType, - $this->compressed - ) && ($length <= self::CHUNK_SIZE) - ) { // Dont compress with GZIP / Brotli if header is not listed and size is bigger than 2mb - $this->end($body); - } else { - for ($i = 0; $i < ceil($length / self::CHUNK_SIZE); $i++) { - $this->write(substr($body, ($i * self::CHUNK_SIZE), min(self::CHUNK_SIZE, $length - ($i * self::CHUNK_SIZE)))); - } - - $this->end(); - } - - $this->disablePayload(); - } else { - $this->end(); - } + parent::send($body); } - /** * YAML *