コード例 #1
0
ファイル: Cookies.php プロジェクト: Trivivium/Cascade
 /**
  * Executes the stored middleware routine.
  *
  * @param RequestInterface $request
  * @param TaskInterface    $task
  * @param callable         $next
  *
  * @return ResponseInterface
  */
 public function execute(RequestInterface $request, TaskInterface $task, callable $next) : ResponseInterface
 {
     $collection = new Collection($_COOKIE);
     $accessor = new CookieAccessor($collection);
     $this->container->bind($accessor);
     /**
      * @var ResponseInterface $response
      */
     $response = $next($request, $task);
     /*
      * Update the response to include new cookies and
      * delete existing ones by overriding them.
      */
     foreach ($collection->all() as $name => $cookie) {
         /*
          * Check if the cookie has an 'expiration' key. Only new cookies
          * has this attribute and therefore only those should be added to the
          * response headers.
          */
         if (!array_key_exists('expiration', $cookie)) {
             continue;
         }
         $response->headers()->write('Set-Cookie', $this->build($name, $cookie), false);
     }
     return $response;
 }
コード例 #2
0
ファイル: Content.php プロジェクト: Trivivium/Cascade
 /**
  * Updates the content length response header.
  */
 private function updateContentLength()
 {
     $this->headers->write('Content-length', strlen($this->content), true);
 }