Пример #1
0
 /**
  *  Sets the array based headers into the Response
  *
  * @param Response $response
  * @param $headers
  */
 private function _setHeadersIntoResponse(Response $response, $headers)
 {
     foreach ($headers as $key => $value) {
         $response->getHeaders()->set($key, $value);
     }
 }
 /**
  * RFC 2616 / 14.21 (Expires)
  *
  * @test
  */
 public function makeStandardsCompliantRemovesMaxAgeDireciveIfExpiresHeaderIsPresent()
 {
     $now = \DateTime::createFromFormat(DATE_RFC2822, 'Tue, 22 May 2012 12:00:00 GMT');
     $later = \DateTime::createFromFormat(DATE_RFC2822, 'Wed, 23 May 2012 12:00:00 GMT');
     $request = Request::create(new Uri('http://localhost'));
     $response = new Response();
     $response->setNow($now);
     $response->setMaximumAge(60);
     $response->setExpires($later);
     $response->makeStandardsCompliant($request);
     $this->assertSame(null, $response->getHeaders()->getCacheControlDirective('max-age'));
     $this->assertEquals($later, $response->getExpires());
 }
 /**
  * Adds an HTTP header to the Response which indicates that the application is powered by Flow.
  *
  * @param Response $response
  * @return void
  */
 protected function addPoweredByHeader(Response $response)
 {
     if ($this->settings['http']['applicationToken'] === 'Off') {
         return;
     }
     $applicationIsFlow = $this->settings['core']['applicationPackageKey'] === 'Neos.Flow';
     if ($this->settings['http']['applicationToken'] === 'ApplicationName') {
         if ($applicationIsFlow) {
             $response->getHeaders()->set('X-Flow-Powered', 'Flow');
         } else {
             $response->getHeaders()->set('X-Flow-Powered', 'Flow ' . $this->settings['core']['applicationName']);
         }
         return;
     }
     /** @var Package $applicationPackage */
     /** @var Package $flowPackage */
     $flowPackage = $this->bootstrap->getEarlyInstance(PackageManagerInterface::class)->getPackage('Neos.Flow');
     $applicationPackage = $this->bootstrap->getEarlyInstance(PackageManagerInterface::class)->getPackage($this->settings['core']['applicationPackageKey']);
     if ($this->settings['http']['applicationToken'] === 'MajorVersion') {
         $flowVersion = $this->renderMajorVersion($flowPackage->getInstalledVersion());
         $applicationVersion = $this->renderMajorVersion($applicationPackage->getInstalledVersion());
     } else {
         $flowVersion = $this->renderMinorVersion($flowPackage->getInstalledVersion());
         $applicationVersion = $this->renderMinorVersion($applicationPackage->getInstalledVersion());
     }
     if ($applicationIsFlow) {
         $response->getHeaders()->set('X-Flow-Powered', 'Flow/' . ($flowVersion ?: 'dev'));
     } else {
         $response->getHeaders()->set('X-Flow-Powered', 'Flow/' . ($flowVersion ?: 'dev') . ' ' . $this->settings['core']['applicationName'] . '/' . ($applicationVersion ?: 'dev'));
     }
 }