Convert to `Set-Cookie` headers
@return string[]
2316
public function toHeaders(): array
    {
        $headers = [];
        foreach ($this as $name => $properties) {
            $headers[] = $this->toHeaderLine($name, $properties);
        }

        return $headers;
    }
928149
protected function cookies()
        {
            $ref = new \ReflectionClass('Symfony\Component\HttpFoundation\Cookie');

            // All of the cookies for the response are actually stored on the
            // Cookie class until we're ready to send the response back to
            // the browser. This allows our cookies to be set easily.
            foreach (Cookie::$jar as $name => $cookie) {
                $config = array_values($cookie);
                $this->headers()->setCookie($ref->newInstanceArgs($config));
            }
        }
500355
public function cookies($request)
    {
        $headers = $response->headers();
        if (!isset($headers['Set-Cookie'])) {
            return [];
        }
        $setCookies = [];
        foreach ($headers['Set-Cookie'] as $setCookieHeader) {
            $setCookie = Cookie::fromString($setCookieHeader);
            if (!$setCookie->domain()) {
                $setCookie->domain($request->hostname());
            }
            if (strpos($setCookie->path(), '/') !== 0) {
                $setCookie->path($this->_pathFrom($request));
            }
            $setCookies[] = $setCookie;
        }
        return $setCookies;
    }
1259510
public function getHeaders()
    {
        if ($this->headers) {
            return $this->headers;
        }

        $this->headers = [
            'STATUS' => $this->code(),
        ];

        $originHeaders = explode("\r\n\r\n", $this->originHeaders);
        $originHeader = array_pop($originHeaders);
        foreach (explode("\r\n", $originHeader) as $i => $header) {
            if ($i == 0 || !$header) {
                continue;
            }

            $header = explode(':', $header, 2);
            $header[0] = strtoupper($header[0]);
            if ($header[0] == 'SET-COOKIE') {
                $this->headers[$header[0]][] = isset($header[1]) ? trim($header[1]) : '';
            } else {
                $this->headers[$header[0]] = isset($header[1]) ? trim($header[1]) : '';
            }
        }

        return $this->headers;
    }
402063
protected static function buildCookieHeader($cookies)
    {
        $headers = [];
        foreach ($cookies as $cookie) {
            $parts = [
                sprintf('%s=%s', urlencode($cookie['name']), urlencode($cookie['value']))
            ];
            if ($cookie['expire']) {
                $cookie['expire'] = gmdate('D, d M Y H:i:s T', $cookie['expire']);
            }
            $attributes = [
                'expire' => 'Expires=%s',
                'path' => 'Path=%s',
                'domain' => 'Domain=%s',
                'httpOnly' => 'HttpOnly',
                'secure' => 'Secure',
            ];
            foreach ($attributes as $key => $attr) {
                if ($cookie[$key]) {
                    $parts[] = sprintf($attr, $cookie[$key]);
                }
            }
            $headers[] = implode('; ', $parts);
        }

        return $headers;
    }
404475
public function sendHeaders()
    {
        // headers have already been sent by the developer
        if (headers_sent()) {
            return $this;
        }

        // headers
        foreach ($this->headers->allPreserveCaseWithoutCookies() as $name => $values) {
            $replace = 0 === strcasecmp($name, 'Content-Type');
            foreach ($values as $value) {
                header($name.': '.$value, $replace, $this->statusCode);
            }
        }

        // cookies
        foreach ($this->headers->getCookies() as $cookie) {
            header('Set-Cookie: '.$cookie->getName().strstr($cookie, '='), false, $this->statusCode);
        }

        // status
        header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);

        return $this;
    }
992245
protected function sendCookies()
    {
        $cookies = $this->getCookies();

        foreach ($cookies as $name => $cookie) {
            setcookie($name, $cookie['value'], (int)$cookie['expire'],
                $cookie['path']);
        }

        return $this;
    }
1169556
protected function convertCookieToArray(CookieInterface $cookie)
    {
        return [
            'name' => $cookie->getName(),
            'value' => $cookie->getValue(),
            'path' => $cookie->getPath(),
            'domain' => $cookie->getDomain(),
            'secure' => $cookie->isSecure(),
            'httponly' => $cookie->isHttpOnly(),
            'expires' => $cookie->getFormattedExpires()
        ];
    }
1007510
protected function parseCookies(): array
    {
        # cookies are encoded in the `cookie` header
        $header = $this->getHeader("cookie");
        if (empty($header)) {
            return [];
        }

        # create a data collection to gracefully handle arrays
        $options = $this->getDecoderOptions();
        $collection = new \sndsgd\http\data\Collection(
            $options->getMaxVars(),
            $options->getMaxNestingLevels()
        );

        foreach (explode(";", $header) as $cookie) {
            $cookie = trim($cookie);
            if ($cookie === "") {
                continue;
            }

            $pair = explode("=", $cookie, 2);
            if (!isset($pair[1]) || $pair[1] === "") {
                continue;
            }

            list($key, $value) = $pair;
            $collection->addValue(urldecode($key), urldecode($value));
        }

        return $collection->getValues();
    }
88239
protected function getHttpHeaders()
    {
        $headers = [];
        if (null !== $this->_maxage) {
            $headers['Cache-Control'] = 'max-age=' . $this->_maxage;
        }
        if ($this->_gzipped) {
            $headers['Content-Encoding'] = 'gzip';
        }

        return $headers;
    }
1183163
private function setHeadersFromCookies()
    {
        $values = [];

        foreach ($this->cookies as $cookie) {
            $values[] = $cookie->toHeader();
        }

        if (!empty($values)) {
            $this->setHeader('Cookie', implode('; ', $values));
        }
    }
756253
protected function parseIncomingCookies($headers)
    {
        $this->incomingTrackerCookies = array();
        
        if (!empty($headers)) {
            $headerName = 'set-cookie:';
            $headerNameLength = strlen($headerName);
            
            foreach($headers as $header) {
                if (strpos(strtolower($header), $headerName) !== 0) {
                    continue;
                }
                $cookies = trim(substr($header, $headerNameLength));
                $posEnd = strpos($cookies, ';');
                if ($posEnd !== false) {
                    $cookies = substr($cookies, 0, $posEnd);
                }
                parse_str($cookies, $this->incomingTrackerCookies);
            }
        }   
    }
575819
public function parseHeader($header)
    {
        $header = rtrim($header, "\r\n");
        $pieces = preg_split('@\s*[;,]\s*@', $header);
        $cookies = array();

        foreach ($pieces as $cookie) {
            $cookie = explode('=', $cookie, 2);

            if (count($cookie) === 2) {
                $key = urldecode($cookie[0]);
                $value = urldecode($cookie[1]);

                if (!isset($cookies[$key])) {
                    $cookies[$key] = $value;
                }
            }
        }

        return $cookies;
    }
284453
private function updateCookieHeader()
	{
		$strings = array();

		foreach ($this->cookies as $key => $value) {
			$strings[] = "{$key}={$value}";
		}

		$this->setHeader('cookie', implode('; ', $strings));
	}
188434
protected function getCookieElement()
    {
        if (! request()->hasCookie(config('cart_manager.cookie_name'))) {
            $cookie = str_random(20);
            Cookie::queue(Cookie::make(
                config('cart_manager.cookie_name'),
                $cookie,
                config('cart_manager.cookie_lifetime')
            ));
        } else {
            $cookie = Cookie::get(config('cart_manager.cookie_name'));
        }

        return ['cookie' => $cookie];
    }
986499
public function sendHeaders()
    {
        // cookie
        foreach($this->cookies as $cookie)
        {
            $this->swooleResponse->cookie($cookie['key'], $cookie['value'], $cookie['expire'] ?? 0, $cookie['path'] ?? '/', $cookie['domain'] ?? '', $cookie['secure'] ?? false, $cookie['httponly'] ?? false);
        }
        // header
        foreach($this->getHeaders() as $name => $headers)
        {
            $this->swooleResponse->header($name, $this->getHeaderLine($name));
        }
        // status
        $this->swooleResponse->status($this->getStatusCode());
        return $this;
    }
993289
protected function prepareCookies()
    {
        $cookiesString = '';

        foreach ($this->cookies as $cookie => $value) {
            $cookiesString .= $cookie.'='.$value.'; ';
        }

        return $cookiesString;
    }