1
0
Fork 0
mirror of synced 2024-07-01 20:50:49 +12:00

response::send

This commit is contained in:
shimon 2022-08-07 14:01:00 +03:00
parent cc93113934
commit f4c1a5ea35
3 changed files with 2 additions and 39 deletions

View file

@ -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'];

View file

@ -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()) {

View file

@ -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
*