Send the HTTP Response Headers
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();
    }
760192
function sendHeaders()
    {
        if ($this->isHeadersSent())
            throw new \Exception('Headers was sent.');

        
        \Poirot\Http\Response\httpResponseCode($this->getMessageObject()->getStatusCode());
        
        /** @var iHeader $header */
        foreach ($this->getMessageObject()->headers() as $header)
            header( $header->render() );

        $this->isHeadersSent = true;
        return $this;
    }
62648
public function send()
  {
    # Set HTTP Response Code
    http_response_code($this->statusCode);

    # Update Cache-Control Header
    if ( empty($this->getHeader('Cache-Control')) ) {
      $this->setHeader('Cache-Control', $this->cacheControl);
    }

    # Set All HTTP headers
    foreach ($this->headers as $header => $value) {
      header($header.': '.$value);
    }

    # Set all cookies
    foreach ($this->cookies as $idx => $cookie) {
      setCookie( $cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly'] );
    }

    # Send Response Body -- if we have something in the $body param
    if ( !empty($this->getBody()) ) {
      echo $this->getBody();
    } else
    if ( !empty($this->getFileBody()) ) {
      readfile($this->getFileBody());
    }

    # Results
    return $this;
  }
414067
public function send(): void
	{
		if($this->body instanceof ResponseSenderInterface)
		{
			// This is a response sender so we'll just pass it the
			// request and response instances and let it handle the rest itself

			$this->body->send($this->request, $this);
		}
		else
		{
			if($this->body instanceof ResponseBuilderInterface)
			{
				$this->body->build($this->request, $this);
			}

			$sendBody = true;

			// Make sure that output buffering is enabled

			if(ob_get_level() === 0)
			{
				ob_start();
			}

			// Cast body to string in case it's an obect implementing __toString

			$this->body = (string) $this->body;

			// Check ETag if response cache is enabled

			if($this->responseCache === true)
			{
				$hash = '"' . hash('sha256', $this->body) . '"';

				$this->headers->add('ETag', $hash);

				if(str_replace('-gzip', '', $this->request->getHeaders()->get('If-None-Match')) === $hash)
				{
					$this->setStatus(304);

					$sendBody = false;
				}
			}

			if($sendBody && !in_array($this->statusCode, [100, 101, 102, 204, 304]))
			{
				// Start compressed output buffering if output compression is enabled

				if($this->outputCompression)
				{
					ob_start('ob_gzhandler');
				}

				echo $this->body;

				// If output compression is enabled then we'll have to flush the compressed buffer
				// so that we can get the compressed content length when setting the content-length header

				if($this->outputCompression)
				{
					ob_end_flush();
				}

				// Add the content-length header

				if(!$this->headers->has('Transfer-Encoding'))
				{
					$this->headers->add('Content-Length', ob_get_length());
				}
			}

			// Send the headers and flush the output buffer

			$this->sendHeaders();

			ob_end_flush();
		}
	}
1335263
private function sendHead(): Response
    {
        $this->header($this->status->line($this->version, $this->sapi));
        foreach ($this->headers as $name => $value) {
            $this->header($name . ': ' . $value);
        }

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

        $this->header('Content-type: ' . $this->mimeType);
        if (!$this->headers->contain('X-Request-ID')) {
            $this->header('X-Request-ID: ' . $this->request->id());
        }

        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;
    }
902332
public function send() {
    list ($headers, $blob, $code) = $this->toHttp();
    header('Content-Type: ' . Constants::MIME_TYPE);
    header("X-PHP-Response-Code: $code", TRUE, $code);
    foreach ($headers as $n => $v) {
      header("$n: $v");
    }
    echo $blob;
  }
706306
private void sendResponseHeaders(ChannelHandlerContext ctx, SendResponseHeadersCommand cmd,
      ChannelPromise promise) throws Http2Exception {
    // TODO(carl-mastrangelo): remove this check once https://github.com/netty/netty/issues/6296 is
    // fixed.
    int streamId = cmd.stream().id();
    Http2Stream stream = connection().stream(streamId);
    if (stream == null) {
      resetStream(ctx, streamId, Http2Error.CANCEL.code(), promise);
      return;
    }
    if (cmd.endOfStream()) {
      closeStreamWhenDone(promise, streamId);
    }
    encoder().writeHeaders(ctx, streamId, cmd.headers(), 0, cmd.endOfStream(), promise);
  }
884655
protected function sendHeaders()
    {
        if (headers_sent($file, $line)) {
            throw new HeadersAlreadySentException($file, $line);
        }
        if ($this->_headerCollection) {
            foreach ($this->getHeaders() as $name => $values) {
                $name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name)));
                // set replace for first occurrence of header but false afterwards to allow multiple
                $replace = true;
                foreach ($values as $value) {
                    header("$name: $value", $replace);
                    $replace = false;
                }
            }
        }
        $statusCode = $this->getStatusCode();
        $protocolVersion = $this->getProtocolVersion();
        header("HTTP/{$protocolVersion} {$statusCode} {$this->reasonPhrase}");
        $this->sendCookies();
    }
1267866
public function sendHeaders()
    {
        if (headers_sent() === true) {
            return;
        }
        foreach ($this->renderHeaders() as $header) {
            header($header, false);
        }
        foreach ($this->headers->getCookies() as $cookie) {
            header('Set-Cookie: ' . $cookie, false);
        }
    }
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;
    }
451849
protected void sendServerResponse(HttpMessage response) {
        designer.http().server(httpServer).send()
                .response(response.getStatusCode())
                .message(response);
    }
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;
    }
662002
protected function sendHeader()
	{
		$this->openHandle();

		$target= $this->path.($this->query? '?'.$this->query : '' ).($this->fragment? '#'.$this->fragment : '' );

		$this->writeLine("{$this->method} {$target} HTTP/{$this->version}");
		$this->writeLine("Host: {$this->host}");

		foreach( $this->headers as $key=>$value ){
			$this->writeLine("$key: $value");
		}
		$this->writeLine('');
	}
983061
public function send_http_headers() {
        $this->writer = \Box\Spout\Writer\WriterFactory::create($this->spouttype);
        if (method_exists($this->writer, 'setTempFolder')) {
            $this->writer->setTempFolder(make_request_directory());
        }
        $filename = $this->filename . $this->get_extension();
        $this->writer->openToBrowser($filename);

        // By default one sheet is always created, but we want to rename it when we call start_sheet().
        $this->renamecurrentsheet = true;
    }
944321
private static function headers() {
        if (empty(self::$config['httpHeaders'])) {
            return;
        }

        $response = self::$config['httpContext']->getResponse();
        $response->setHeaders(self::$config['httpHeaders']);
    }
196481
public function sendHeaders()
    {
        if($this->getRequesthandler()->getRequestMethod() == Jaxon::METHOD_GET)
        {
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
            header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
            header("Cache-Control: no-cache, must-revalidate");
            header("Pragma: no-cache");
        }

        $sCharacterSet = '';
        $sCharacterEncoding = trim($this->getOption('core.encoding'));
        if(($sCharacterEncoding) && strlen($sCharacterEncoding) > 0)
        {
            $sCharacterSet = '; charset="' . trim($sCharacterEncoding) . '"';
        }

        header('content-type: ' . $this->sContentType . ' ' . $sCharacterSet);
    }