response::send
This commit is contained in:
parent
cc93113934
commit
f4c1a5ea35
3 changed files with 2 additions and 39 deletions
|
@ -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'];
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -457,51 +457,14 @@ 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))));
|
||||
parent::send($body);
|
||||
}
|
||||
|
||||
$this->end();
|
||||
}
|
||||
|
||||
$this->disablePayload();
|
||||
} else {
|
||||
$this->end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* YAML
|
||||
|
|
Loading…
Reference in a new issue