Send the headers
@return self
779531
public function send()
    {
        if ($this->sent()) {
            throw new Exceptions\HeadersAlreadySentException(
                "Headers already sent"
            );
        }

        $this->sent = true;

        foreach ($this as $header) {
            $header->send();
        }

        return $this;
    }
435096
public function sendHeader()
    {
        $file = $line = null;
        if ($this->isHeaderSent($file, $line)) {
            if ($this->wei->has('logger')) {
                $this->logger->debug(sprintf('Header has been at %s:%s', $file, $line));
            }
            return false;
        }

        // Send status
        $this->sendRawHeader(sprintf('HTTP/%s %d %s', $this->version, $this->statusCode, $this->statusText));

        // Send headers
        foreach ($this->headers as $name => $values) {
            foreach ($values as $value) {
                $this->sendRawHeader($name . ': ' . $value);
            }
        }

        $this->sendCookie();

        return true;
    }
1241922
public static function sendHeaders()
    {
        if (! headers_sent()) {
            foreach (self::$headers as $header) {
                header($header, true);
            }

            return true;
        }

        return false;
    }
1117588
public function send()
        {
            // Default options
            $this->setCurlOption(CURLOPT_RETURNTRANSFER, true);
            $this->setCurlOption(CURLINFO_HEADER_OUT, true);

            // Additional headers
            if(isset($this->options['headers']) && count($this->options['headers']) > 0) {
                $this->options['request_headers'] = array_merge($this->options['request_headers'], $this->options['headers']);
            }

            // SSL
            if(isset($this->options['ssl'])) {
                $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, true);
                $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 2);
                $this->setCurlOption(CURLOPT_CAINFO, getcwd() . $this->options['ssl']);
            }

            // Payload
            if(isset($this->options['is_payload']) && $this->options['is_payload'] === true) {
                // Appropriate headers for sending a JSON object
                $this->options['request_headers'] = array_merge($this->options['request_headers'], [
                    'Content-Type: application/json',
                    'Content-Length: ' . ((isset($this->options['data'])) ? strlen(json_encode($this->options['data'])) : 0)
                ]);
            }

            // Set headers
            if (count($this->options['request_headers']) > 0) {
                $this->setCurlOption(CURLOPT_HTTPHEADER, $this->options['request_headers']);
            }

            // Retrieving HTTP response body
            $this->response = curl_exec($this->ch);

            // Retrieving HTTP status code
            $this->status = $this->getCurlInfo(CURLINFO_HTTP_CODE);

            // Retrieving HTTP header
            $this->header = $this->getCurlInfo(CURLINFO_HEADER_OUT);

            // Autoclose handle
            if(!isset($this->options['autoclose']) || (isset($this->options['autoclose']) && $this->options['autoclose'] !== false)) {
                $this->close();
            }

            return $this;
        }
954105
function sendHeaders()
    {
        if ($this->isHeadersSent())
            throw new \Exception('Headers was sent.');

        $response = $this->getMessageObject();

        // Step 1: Send the "status line".
        $statusLine = sprintf('HTTP/%s %s %s'
            , $response->getProtocolVersion()
            , $response->getStatusCode()
            , $response->getReasonPhrase()
        );
        header($statusLine, true); /* The header replaces a previous similar header. */


        // Step 2: Send the response headers from the headers list.
        foreach ($response->getHeaders() as $name => $values) {
            $responseHeader = sprintf('%s: %s'
                , $name
                , $response->getHeaderLine($name)
            );
            header($responseHeader, false); /* The header doesn't replace a previous similar header. */
        }

        $this->isHeadersSent = true;
        return $this;
    }
593270
protected function send_headers() {
        header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0');
        header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT');
        header('Pragma: no-cache');
        header('Accept-Ranges: none');
        header('Content-Length: ' . strlen($this->response));
        header('Content-Type: application/xml; charset=utf-8');
        header('Content-Disposition: inline; filename="response.xml"');
    }
1033347
public function send()
    {
        // gzip支持
        if($this->gzipStatus)
        {
            $this->swooleResponse->gzip($this->gzipLevel);
        }
        $this->sendHeaders();
        $this->swooleResponse->end($this->getBody());
        $this->isEnded = true;
        return $this;
    }
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;
    }
74422
private function _addHeaderRequirements()
    {
        $this->_headerRequirements = array();
        foreach ($this->getRequirements() as $key => $value) {
            if (0 === strpos($key, 'HTTP-')) {
                $this->_headerRequirements[substr($key, 5)] = $value;
            }
        }

        return $this;
    }
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;
    }
1169055
private function sendHeaders()
    {
        // Send status code header
        if (PHP_SAPI == 'cli') {
            header(
                sprintf(
                    'Status: %d %s',
                    $this->status,
                    $this->getStatusText()
                ),
                true
            );
        }
        else {
            // @codeCoverageIgnoreStart
            header(
                sprintf(
                    '%s %d %s',
                    (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'),
                    $this->status,
                    $this->getStatusText()
                ),
                true,
                $this->status
            );
            // @codeCoverageIgnoreEnd
        }

        // Send other headers
        foreach ($this->headers as $field => $value) {
            if (is_array($value)) {
                foreach ($value as $v) {
                    header($field . ': ' . $v, false);
                }
            }
            else {
                header($field . ': ' . $value);
            }
        }

        // Send content length
        if (($length = strlen($this->content)) > 0) {
            header('Content-Length: ' . $length);
        }

        return $this;
    }
76482
private function sendHeaders()
    {
        foreach ($this->body->getHeaders() as $key => $value) {
            $key = join('-', array_map('ucfirst', explode('-', $key)));
            header(sprintf('%s: %s', $key, $value));
        }
    }
992245
protected function sendCookies()
    {
        $cookies = $this->getCookies();

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

        return $this;
    }
495424
public function sendHeaders(): void
    {
        foreach ((array) $this->headers as $name => $value) {
            $this->sendHeader($name, $value);
        }
    }
421560
public function sendHeaders()
    {
        $codes = $this->getHttpResponseCodes();
        if (!array_key_exists($this->status, $codes)) {
            $this->status = 500;
            $string = 'HTTP/1.0 500 ' . $codes[500];
        } else {
            if ($this->isValidRedirectStatus()) {
                throw new \Exception(
                    'You cannot send a redirect using a regular response. Use $this->response->redirect(url, status);'
                );
            }
            $string = 'HTTP/1.0 ' . $this->status . ' ' . $codes[$this->status];
        }

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

        $response = self::$config['httpContext']->getResponse();
        $response->setHeaders(self::$config['httpHeaders']);
    }
738267
public function sendHeaders(HeaderBag $headers)
    {
        # First, remove all headers on the response object
        $headersToRemove = $this->response->getHeaders();
        foreach ($headersToRemove as $name => $headerLines)
        {
            $this->response = $this->response->withoutHeader($name);
        }

        # And then, reset all headers from the HeaderBag instance
        foreach ($headers->get() as $header)
        {
            $this->response = $this->response->withAddedHeader(
                $header->getName(),
                $header->getValue()
            );
        }
    }