/** * Constructor. * * If the filter finds an existing cache entry for the given request, then it loads it and sets "stopRoute" to true. * @todo Add \Niysu\Services\ResourcesCacheService for third parameter */ public function __construct(\Niysu\HTTPRequestInterface $request, \Niysu\HTTPResponseInterface $response, $resourcesCacheService, &$stopRoute, \Monolog\Logger $log = null) { $this->outputResponse = $response; $this->request = $request; $this->responseStorage = new \Niysu\HTTPResponseStorage(); $this->cacheService = $resourcesCacheService; $this->log = $log; if ($request->getMethod() == 'GET') { $this->writeInCache = true; $this->transmitToParent = true; $this->ttl = 300; // 5mn // attempting to load from cache if ($loadedData = $resourcesCacheService->load($request->getURL(), $request->getHeadersList())) { $this->writeInCache = false; $this->transmitToParent = false; $fp = \Niysu\HTTPResponseStream::build($this->getOutput(), true); $fp->fwrite($loadedData); $stopRoute = true; } } else { $this->writeInCache = false; $this->transmitToParent = true; } }
public function __construct(\Niysu\HTTPResponseInterface $response, \Niysu\HTTPRequestInterface $request, &$stopRoute) { $this->outputResponse = $response; $this->requestETag = $request->getHeader('If-None-Match'); $this->stopRoute =& $stopRoute; }
private static function isGlobalRequest(\Niysu\HTTPRequestInterface $rq) { if ($rq instanceof \Niysu\HTTPRequestGlobal) { return true; } if ($rq instanceof \Niysu\HTTPRequestFilterInterface) { return $rq->getInput(); } return false; }