/** * {@inheritdoc} */ protected function setHeaders(Response $response, ImageInterface $image, \DateTime $lastMod) { $response->headers->set('Content-type', $image->getMimeType()); $response->setContent($content = $image->getContents()); $response->setLastModified($lastMod); $response->setEtag(hash('md5', $response->getContent())); $response->headers->set('Accept-ranges', 'bytes'); $response->headers->set('Keep-Alive', 'timeout=15, max=200'); $response->headers->set('Connection', 'Keep-Alive', true); }
/** * {@inheritdoc} */ protected function setHeaders(Response $response, ImageInterface $image, \DateTime $lastMod) { $response->headers->set('Content-type', $image->getMimeType()); $response->setLastModified($lastMod); $response->headers->set('Accept-ranges', 'bytes'); $response->headers->set('Keep-Alive', 'timeout=5, max=99'); $response->headers->set('Connection', 'keep-alive', true); // return normal by setting image contents; if ($image->isProcessed()) { $response->setContent($content = $image->getContents()); $response->setEtag(hash('md5', $content)); } else { // set the xsend header: $file = $image->getSource(); $response->setEtag(md5_file($file)); $response->headers->set('Content-Length', filesize($file)); $response->headers->set('Content-Disposition', sprintf('inline; filename="%s"', basename($file))); $response->headers->set('X-Sendfile', $file); } }
/** * {@inheritDoc} */ public function resolve() { $this->image->close(); if (!$this->canResolve()) { return false; } $this->parseAll(); if ($this->config->cache && ($image = $this->resolveFromCache($id = $this->getImageRequestId($this->getInputQuery(), $this->input['source'])))) { return $image; } // something went wrong if (!($img = $this->isReadableFile($this->parameter))) { return false; } // something went wrong if (!$this->image->load($img)) { return false; } $this->image->process($this); if ($this->config->cache) { $this->processCache->put($id, $this->image->getContents()); } return $this->image; }