当前位置: 首页>>代码示例>>PHP>>正文


PHP StreamedResponse::isNotModified方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\StreamedResponse::isNotModified方法的典型用法代码示例。如果您正苦于以下问题:PHP StreamedResponse::isNotModified方法的具体用法?PHP StreamedResponse::isNotModified怎么用?PHP StreamedResponse::isNotModified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\StreamedResponse的用法示例。


在下文中一共展示了StreamedResponse::isNotModified方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setHeaders

 /**
  * Set the streamed response headers.
  * @param  StreamedResponse $response The response object.
  * @return StreamedResponse
  */
 public function setHeaders(StreamedResponse $response)
 {
     $response->headers->set('Content-Type', $this->cache->getMimetype($this->path));
     $response->headers->set('Content-Length', $this->cache->getSize($this->path));
     $response->setPublic();
     $response->setMaxAge(31536000);
     $response->setExpires(date_create()->modify('+1 years'));
     $response->setLastModified(date_create()->setTimestamp($this->cache->getTimestamp($this->path)));
     $response->isNotModified($this->request);
     return $response;
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:16,代码来源:ResponseFactory.php

示例2: thread

 protected function thread($num = 0, $options = [])
 {
     $this->profiler->log('Controller Chan::thread Start');
     $num = str_replace('S', '', $num);
     try {
         $board = Board::forge($this->getContext())->getThread($num)->setRadix($this->radix)->setOptions($options);
         // get the current status of the thread
         $thread_status = $board->getThreadStatus();
         $last_modified = $thread_status['last_modified'];
         $this->setLastModified($last_modified);
         if (!$this->response->isNotModified($this->request)) {
             $this->response = new StreamedResponse();
             $this->setLastModified($last_modified);
             // execute in case there's more exceptions to handle
             $thread = $board->getComments();
             // get the latest doc_id and latest timestamp for realtime stuff
             $latest_doc_id = $board->getHighest('doc_id')->comment->doc_id;
             $latest_timestamp = $board->getHighest('timestamp')->comment->timestamp;
             $this->builder->getProps()->addTitle(_i('Thread') . ' #' . $num);
             $this->param_manager->setParams(['thread_id' => $num, 'is_thread' => true, 'disable_image_upload' => $thread_status['disable_image_upload'], 'thread_dead' => $thread_status['dead'], 'latest_doc_id' => $latest_doc_id, 'latest_timestamp' => $latest_timestamp, 'thread_op_data' => $thread[$num]['op']]);
             $this->builder->createPartial('body', 'board')->getParamManager()->setParams(['board' => $board->getComments()]);
             $backend_vars = $this->param_manager->getParam('backend_vars');
             $backend_vars['thread_id'] = $num;
             $backend_vars['latest_timestamp'] = $latest_timestamp;
             $backend_vars['latest_doc_id'] = $latest_doc_id;
             $backend_vars['board_shortname'] = $this->radix->shortname;
             if (isset($options['last_limit']) && $options['last_limit']) {
                 $this->param_manager->setParam('controller_method', 'last/' . $options['last_limit']);
                 $backend_vars['last_limit'] = $options['last_limit'];
             }
             $this->param_manager->setParam('backend_vars', $backend_vars);
             if (!$thread_status['closed']) {
                 $this->builder->createPartial('tools_reply_box', 'tools_reply_box');
             }
             $this->profiler->logMem('Controller Chan $this', $this);
             $this->profiler->log('Controller Chan::thread End');
             $this->response->setCallback(function () {
                 $this->builder->stream();
             });
         }
     } catch (\Foolz\Foolfuuka\Model\BoardThreadNotFoundException $e) {
         $this->profiler->log('Controller Chan::thread End Prematurely');
         return $this->error($e->getMessage(), 404);
     } catch (\Foolz\Foolfuuka\Model\BoardException $e) {
         $this->profiler->log('Controller Chan::thread End Prematurely');
         return $this->error($e->getMessage());
     }
     return $this->response;
 }
开发者ID:procod3R,项目名称:FoolFuuka,代码行数:49,代码来源:Chan.php

示例3: manifestAction

 /**
  * @param string  $build
  * @param Request $request
  * @return Response
  */
 public function manifestAction($build, Request $request)
 {
     $this->closeSession($request);
     try {
         $manifest = $this->application->getManifest($build);
     } catch (FileNotFoundException $e) {
         throw new NotFoundHttpException('Not Found', $e);
     }
     $response = new StreamedResponse(function () {
         echo '';
     });
     $response->setETag($manifest->computeETag())->setLastModified(\DateTime::createFromFormat('U', $manifest->getMTime()))->setPublic();
     if ($response->isNotModified($request)) {
         return $response;
     }
     $response->setCallback(function () use($manifest) {
         echo $manifest->getContent();
     });
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
开发者ID:teqneers,项目名称:ext-application-bundle,代码行数:26,代码来源:ExtJSController.php

示例4: execute

 public function execute(Request $request, WorkingFolder $workingFolder, EventDispatcher $dispatcher, Config $config)
 {
     $fileName = (string) $request->query->get('fileName');
     $thumbnailFileName = (string) $request->query->get('thumbnail');
     if (!File::isValidName($fileName, $config->get('disallowUnsafeCharacters'))) {
         throw new InvalidRequestException(sprintf('Invalid file name: %s', $fileName));
     }
     $cacheLifetime = (int) $request->query->get('cache');
     if (!$workingFolder->containsFile($fileName)) {
         throw new FileNotFoundException();
     }
     if ($thumbnailFileName) {
         if (!File::isValidName($thumbnailFileName, $config->get('disallowUnsafeCharacters'))) {
             throw new InvalidRequestException(sprintf('Invalid resized image file name: %s', $fileName));
         }
         if (!$workingFolder->getResourceType()->isAllowedExtension(pathinfo($thumbnailFileName, PATHINFO_EXTENSION))) {
             throw new InvalidExtensionException();
         }
         $resizedImageRespository = $this->app->getResizedImageRepository();
         $file = $resizedImageRespository->getExistingResizedImage($workingFolder->getResourceType(), $workingFolder->getClientCurrentFolder(), $fileName, $thumbnailFileName);
         $dataStream = $file->readStream();
     } else {
         $file = new DownloadedFile($fileName, $this->app);
         $file->isValid();
         $dataStream = $workingFolder->readStream($file->getFilename());
     }
     $proxyDownload = new ProxyDownloadEvent($this->app, $file);
     $dispatcher->dispatch(CKFinderEvent::PROXY_DOWNLOAD, $proxyDownload);
     if ($proxyDownload->isPropagationStopped()) {
         throw new AccessDeniedException();
     }
     $response = new StreamedResponse();
     $response->headers->set('Content-Type', $file->getMimeType());
     $response->headers->set('Content-Length', $file->getSize());
     $response->headers->set('Content-Disposition', 'inline; filename="' . $fileName . '"');
     if ($cacheLifetime > 0) {
         Utils::removeSessionCacheHeaders();
         $response->setPublic();
         $response->setEtag(dechex($file->getTimestamp()) . "-" . dechex($file->getSize()));
         $lastModificationDate = new \DateTime();
         $lastModificationDate->setTimestamp($file->getTimestamp());
         $response->setLastModified($lastModificationDate);
         if ($response->isNotModified($request)) {
             return $response;
         }
         $response->setMaxAge($cacheLifetime);
         $expireTime = new \DateTime();
         $expireTime->modify('+' . $cacheLifetime . 'seconds');
         $response->setExpires($expireTime);
     }
     $chunkSize = 1024 * 100;
     $response->setCallback(function () use($dataStream, $chunkSize) {
         if ($dataStream === false) {
             return false;
         }
         while (!feof($dataStream)) {
             echo fread($dataStream, $chunkSize);
             flush();
             @set_time_limit(8);
         }
         return true;
     });
     return $response;
 }
开发者ID:knodejs,项目名称:ckfinder_gulp,代码行数:64,代码来源:Proxy.php


注:本文中的Symfony\Component\HttpFoundation\StreamedResponse::isNotModified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。