Sets headers that will instruct the client to cache this response.

@return static self reference
341453
public function setCacheHeaders()
    {
        $cacheTime = 31536000; // 1 year
        $this->getHeaders()
            ->set('Expires', gmdate('D, d M Y H:i:s', time() + $cacheTime) . ' GMT')
            ->set('Pragma', 'cache')
            ->set('Cache-Control', 'max-age=' . $cacheTime);

        return $this;
    }
540095
public function setHeaders($headers)
    {
        $headers = StdObjectWrapper::toArray($headers);
        $this->message->setHeaders($headers);

        return $this;
    }
308446
public function sendHeaders()
    {
        if (!headers_sent()) {
            foreach ($this->headers as $header) {
                header($header, true);
            }
        }

        $this->headers = array();
        return $this;
    }
860933
public function build(): SetExtraHTTPHeadersRequest
	{
		$instance = new SetExtraHTTPHeadersRequest();
		if ($this->headers === null) {
			throw new BuilderException('Property [headers] is required.');
		}
		$instance->headers = $this->headers;
		return $instance;
	}
100048
protected function prepareHeaders()
    {
        $headers = array();

        foreach ($this->headers as $header => $value) {
            $headers[] = $header.': '.$value;
        }

        return $headers;
    }
270321
public function setCacheHeader()
    {
        if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
            $this->setStatus(304);
            exit;
        }

        $this->setHeader('Expires', gmdate('D, d M Y H:i:s', time() + 365 * 24 * 60 * 60) . ' GMT');
        $this->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT');
        $this->setHeader('Cache-Control', 'immutable');
    }
695649
public function setHeaders(array $headers)
    {
        if ($headers) {
            $this->headers = array_merge($this->headers, $headers);
        }

        return $this;
    }
314632
public function sendHeaders()
    {
        foreach ($this->getHeaders() as $name => $values) {
            foreach ($values as $value) {
                header(sprintf('%s: %s', $name, $value), false);
            }
        }

        return $this;
    }
1037124
public function setRequestHeader($header, $value) {
        $this->request = $this->request->withHeader($header, $value);

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

        /* RFC2616 - 14.18 says all Responses need to have a Date */
        if (!$this->headers->has('Date')) {
            $this->setDate(\DateTime::createFromFormat('U', time()));
        }

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

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

        // cookies
        foreach ($this->headers->getCookies() as $cookie) {
            if ($cookie->isRaw()) {
                setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
            } else {
                setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
            }
        }

        return $this;
    }
376545
public function setHeaders(array $headers)
    {
        foreach ($headers as $key => $value) {
            $this->headers[$key] = $value;
        }

        return $this;
    }
91022
public function sendHeaders()
	{
		// Early return if headers already have been send
		if (headers_sent()) {
			return $this;
		}

		foreach ($this->headers as $key => $value) {
			header(
				sprintf('%s: %s', $key, is_array($value) ? implode('; ', $value) : $value),
				true,
				$this->statusCode
			);
		}

		header(sprintf('%s %s %s',
			self::$protocolVersionMap[$this->protocolVersion],
			$this->statusCode,
			self::$statusCodeMap[$this->statusCode]
		));

		return $this;
	}
1180967
protected function addHeaders()
    {
        if (empty($this->headers)) {
            return $this;
        }

        $this->options[CURLOPT_HTTPHEADER] = $this->headers;
        return $this;
    }
944321
private static function headers() {
        if (empty(self::$config['httpHeaders'])) {
            return;
        }

        $response = self::$config['httpContext']->getResponse();
        $response->setHeaders(self::$config['httpHeaders']);
    }
559613
public function sendHeaders(): self
    {
        // headers have already been sent by the developer
        if (\headers_sent()) {
            return $this;
        }

        /* RFC2616 - 14.18 says all Responses need to have a Date */
        if (!$this->header->has('Date')) {
            $this->setDate(\DateTime::createFromFormat('U', (string) \time()));
        }

        // status
        \header('HTTP/' . $this->version . ' ' . $this->status . ' ' . $this->reason, true, $this->status);

        // headers
        $headers = $this->header->all();
        $this->cookie->inject($headers);

        foreach ($this->header->all() as $name => $values) {
            $first = true;
            foreach ($values as $value) {
                \header($name . ': ' . $value, $first, $this->status);
                $first = false;
            }
        }

        return $this;
    }
734982
protected function _prepareHeaders()
    {
        $headers = array();

        // Set the host header
        if (! isset($this->headers['host'])) {
            $host = $this->uri->getHost();

            // If the port is not default, add it
            if (! (($this->uri->getScheme() == 'http' && $this->uri->getPort() == 80) ||
                  ($this->uri->getScheme() == 'https' && $this->uri->getPort() == 443))) {
                $host .= ':' . $this->uri->getPort();
            }

            $headers[] = "Host: {$host}";
        }

        // Set the connection header
        if (! isset($this->headers['connection'])) {
            if (! $this->config['keepalive']) {
                $headers[] = "Connection: close";
            }
        }

        // Set the Accept-encoding header if not set - depending on whether
        // zlib is available or not.
        if (! isset($this->headers['accept-encoding'])) {
            if (function_exists('gzinflate')) {
                $headers[] = 'Accept-encoding: gzip, deflate';
            } else {
                $headers[] = 'Accept-encoding: identity';
            }
        }
        
        // Set the Content-Type header
        if ($this->method == self::POST &&
           (! isset($this->headers[strtolower(self::CONTENT_TYPE)]) && isset($this->enctype))) {

            $headers[] = self::CONTENT_TYPE . ': ' . $this->enctype;
        }
        
        // Set the user agent header
        if (! isset($this->headers['user-agent']) && isset($this->config['useragent'])) {
            $headers[] = "User-Agent: {$this->config['useragent']}";
        }

        // Set HTTP authentication if needed
        if (is_array($this->auth)) {
            $auth = self::encodeAuthHeader($this->auth['user'], $this->auth['password'], $this->auth['type']);
            $headers[] = "Authorization: {$auth}";
        }

        // Load cookies from cookie jar
        if (isset($this->cookiejar)) {
            $cookstr = $this->cookiejar->getMatchingCookies($this->uri,
                true, Zend_Http_CookieJar::COOKIE_STRING_CONCAT);

            if ($cookstr) {
                $headers[] = "Cookie: {$cookstr}";
            }
        }

        // Add all other user defined headers
        foreach ($this->headers as $header) {
            list($name, $value) = $header;
            if (is_array($value)) {
                $value = implode(', ', $value);
            }

            $headers[] = "$name: $value";
        }

        return $headers;
    }
273477
public function sendHeaders()
	{
		if (!$this->checkHeadersSent())
		{
			foreach ($this->response->headers as $header)
			{
				if ('status' == strtolower($header['name']))
				{
					// 'status' headers indicate an HTTP status, and need to be handled slightly differently
					$this->header(ucfirst(strtolower($header['name'])) . ': ' . $header['value'], null, (int) $header['value']);
				}
				else
				{
					$this->header($header['name'] . ': ' . $header['value']);
				}
			}
		}

		return $this;
	}