See also: http://tools.ietf.org/html/rfc6265
 /**
  * Creates a response from the given raw, that is plain text, HTTP response.
  *
  * @param string $rawResponse
  * @param Response $parentResponse Parent response, if called recursively
  *
  * @throws \InvalidArgumentException
  * @return Response
  */
 public static function createFromRaw($rawResponse, Response $parentResponse = null)
 {
     $response = new static($parentResponse);
     $lines = explode(chr(10), $rawResponse);
     $statusLine = array_shift($lines);
     if (substr($statusLine, 0, 5) !== 'HTTP/') {
         throw new \InvalidArgumentException('The given raw HTTP message is not a valid response.', 1335175601);
     }
     list($version, $statusCode, $reasonPhrase) = explode(' ', $statusLine, 3);
     $response->setVersion($version);
     $response->setStatus((int) $statusCode, trim($reasonPhrase));
     $parsingHeader = true;
     $contentLines = [];
     $headers = new Headers();
     foreach ($lines as $line) {
         if ($parsingHeader) {
             if (trim($line) === '') {
                 $parsingHeader = false;
                 continue;
             }
             $fieldName = trim(substr($line, 0, strpos($line, ':')));
             $fieldValue = trim(substr($line, strlen($fieldName) + 1));
             if (strtoupper(substr($fieldName, 0, 10)) === 'SET-COOKIE') {
                 $cookie = Cookie::createFromRawSetCookieHeader($fieldValue);
                 if ($cookie !== null) {
                     $headers->setCookie($cookie);
                 }
             } else {
                 $headers->set($fieldName, $fieldValue, false);
             }
         } else {
             $contentLines[] = $line;
         }
     }
     $content = implode(chr(10), $contentLines);
     $response->setHeaders($headers);
     $response->setContent($content);
     return $response;
 }
 /**
  * Sets a cookie
  *
  * @param Cookie $cookie
  * @return void
  * @api
  */
 public function setCookie(Cookie $cookie)
 {
     $this->cookies[$cookie->getName()] = $cookie;
 }
 /**
  * @test
  */
 public function createCookieFromRawSetsHttpOnlyIfPresent()
 {
     $cookie = Cookie::createFromRawSetCookieHeader('ckName=someValue; HttpOnly; more=nothing');
     $this->assertTrue($cookie->isHttpOnly());
 }
 /**
  * Automatically expires the session if the user has been inactive for too long.
  *
  * @return boolean TRUE if the session expired, FALSE if not
  */
 protected function autoExpire()
 {
     $lastActivitySecondsAgo = $this->now - $this->lastActivityTimestamp;
     $expired = false;
     if ($this->inactivityTimeout !== 0 && $lastActivitySecondsAgo > $this->inactivityTimeout) {
         $this->started = true;
         $this->sessionIdentifier = $this->sessionCookie->getValue();
         $this->destroy(sprintf('Session %s was inactive for %s seconds, more than the configured timeout of %s seconds.', $this->sessionIdentifier, $lastActivitySecondsAgo, $this->inactivityTimeout));
         $expired = true;
     }
     return $expired;
 }