Encrypt the cookies on an outgoing response.

@param  \Symfony\Component\HttpFoundation\Response  $response
@return \Symfony\Component\HttpFoundation\Response
497029
protected function encrypt(Response $response)
    {
        foreach ($response->headers->getCookies() as $cookie) {
            if ($this->isDisabled($cookie->getName())) {
                continue;
            }

            $response->headers->setCookie($this->duplicate(
                $cookie, $this->encrypter->encrypt($cookie->getValue(), static::serialized($cookie->getName()))
            ));
        }

        return $response;
    }
1248642
public function getUserFromTokenResponse($response)
    {
        $user = $this->mapUserToObject($this->getUserByToken(
            $token = $this->parseAccessToken($response)
        ));

        $this->credentialsResponseBody = $response;

        if ($user instanceof User) {
            $user->setAccessTokenResponseBody($this->credentialsResponseBody);
        }

        return $user->setToken($token)
            ->setRefreshToken($this->parseRefreshToken($response))
            ->setExpiresIn($this->parseExpiresIn($response));
    }
912337
protected function _withCustomHeaders($response)
    {
        foreach ((array)$this->getConfig('headers') as $key => $value) {
            $response = $response->withHeader($key, $value);
        }

        return $response;
    }
1071495
public static function fromString($response)
	{
		$code 	 = self::extractCode($response);
		$headers = self::extractHeaders($response);
		$body 	 = self::extractBody($response);
		$version = self::extractVersion($response);
		$message = self::extractMessage($response);
		
		# FIX FOR MULTIPLE HTTP RESPONSE CODE RETURNED BY SERVER 
		if ($code === 100 && count($headers) === 0 && self::extractCode($body)) {
			return self::fromString($body);
		}
		
		return new static($code, $headers, $body, $version, $message);
	}
277369
public static function fromResponse(ResponseInterface $response)
    {
        $responseBody = (string) $response->getBody();
        if (empty($responseBody)) {
            return new self($response->getStatusCode(), $response->getReasonPhrase());
        }

        $decodedBody = json_decode($responseBody, true);
        if (!isset($decodedBody['error'])) {
            return new self($response->getStatusCode(), $response->getReasonPhrase());
        }

        $error = $decodedBody['error'];

        return new self($response->getStatusCode(), $error['message'], $error['type'], $error);
    }
1306643
public static function onRequest($request, $response) {
		$request = new Request($request);
		$request->setCookieHandler([$response, 'cookie']);
		$response = new Response($response);
		Container::getInstance()
			->get(Dispatcher::class)
			->handleRequest($request, $response);
	}
601935
public function update(Response $response)
    {
        $flatCookies = $response->headers->getCookies();
        $cookies = [];

        $getCookieId = function (Cookie $cookie) {
            return $cookie->getDomain() . '|' . $cookie->getPath() . '|' . $cookie->getName();
        };

        /** @var Cookie $cookie */
        foreach ($flatCookies as $cookie) {
            $cookies[$getCookieId($cookie)] = $cookie;
        }

        foreach ($this->cookieModels as $cookieModel) {
            $cookie = $cookieModel->toCookie();

            if ($cookieModel->getClear()) {
                $response->headers->clearCookie($cookie->getName(), $cookie->getPath(), $cookie->getDomain());
            } elseif (!isset($cookies[$getCookieId($cookie)]) && $cookieModel->isDirty()) {
                $response->headers->setCookie($cookieModel->toCookie());
            }
        }
    }
793516
public static function fromResponse(Response $response)
    {
        $header = $response->headers->get('Link');
        if (is_array($header)) {
            implode(',', $header);
        }

        return self::fromString($header);
    }
818500
protected function setResponseHeaders(Response $response)
    {
        $response->headers->set('Access-Control-Allow-Origin', '*');
        $response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');

        return $response;
    }
2230
protected function addCookieToResponse(Response $response, SessionInterface $session)
	{
		if ($this->usingCookieSessions())
		{
			$this->manager->driver()->save();
		}

		if ($this->sessionIsPersistent($config = $this->manager->getSessionConfig()))
		{
			$response->headers->setCookie(new Cookie(
				$session->getName(), $session->getId(), $this->getCookieExpirationDate(),
				$config['path'], $config['domain'], array_get($config, 'secure', false)
			));
		}
	}
629350
protected function interactsWithResponse(Response $response): Response
    {
        if ($response instanceof Filterable && $this instanceof Filterable) {
            $response->setFilterable($this->getFilterable());
        }

        if ($this->validateResponseAutomatically === true) {
            $response->validate();
        }

        return $response;
    }
1159223
protected function addCookieToResponse($request, $response)
    {
        $config = config('session');

        $response->headers->setCookie(
            new Cookie(
                'XSRF-TOKEN', $request->session()->token(), $this->availableAt(60 * $config['lifetime']),
                $config['path'], $config['domain'], $config['secure'], false, false, $config['same_site'] ?? null
            )
        );

        return $response;
    }
636315
protected function setCookieForResponse(Response $response, ResponseAuthenticationModel $responseModel)
    {
        $response->headers->setCookie(
            new Cookie(
                self::AUTH_COOKIE,
                $responseModel->getAuthToken(),
                $responseModel->getTokenExpirationTimeStamp(),
                null,
                false,
                false
            )
        );

        return $response;
    }
879326
protected function configureResponse(ResponseInterface $Response){
        $Response->setRequest($this->Request);
        $Response->extract();
        return $Response;
    }
1133182
public function behave(Response $response)
    {
        return new Response(
            json_decode($response->content(), true),
            $response->contentType(),
            $response->error(),
            $response->errorCode(),
            $response->headerLines(),
            $response->statusCode()
        );
    }
683651
protected function response(Response $response)
    {
        return $this->response->create(
            (string)$response->getContent(),
            $response->getStatusCode(),
            (array)$response->headers->all()
        );
    }
327860
private function encodeCookie(Cookie $cookie): Cookie
    {
        if ($this->config->cookieProtectionMethod() == HttpConfig::COOKIE_ENCRYPT) {
            $encrypter = $this->encryption->getEncrypter();

            return $cookie->withValue($encrypter->encrypt($cookie->getValue()));
        }

        //VALUE.HMAC
        return $cookie->withValue($cookie->getValue() . $this->hmacSign($cookie->getValue()));
    }