Send HTTP headers

@return $this
@throws \Exception headers sent
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;
    }
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;
    }
1241922
public static function sendHeaders()
    {
        if (! headers_sent()) {
            foreach (self::$headers as $header) {
                header($header, true);
            }

            return true;
        }

        return false;
    }
265413
protected function sendWebServiceRequest()
    {
        $this->response = $this->http->post(WebService::SIGEP, [
            'http_errors' => false,
            'body' => $this->body,
            'headers' => [
                'Content-Type' => 'application/xml; charset=utf-8',
                'cache-control' => 'no-cache',
            ],
        ]);

        return $this;
    }
1189850
public function send()
    {
        $curl = curl_init();

        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, false);

        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
        curl_setopt($curl, CURLOPT_URL, $this->url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array());
        curl_setopt($curl, CURLOPT_POSTFIELDS, null);

        curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0 < $this->maxRedirects);
        curl_setopt($curl, CURLOPT_MAXREDIRS, $this->maxRedirects);
        curl_setopt($curl, CURLOPT_FAILONERROR, !$this->ignoreErrors);

        $data = curl_exec($curl);
        if (false === $data) {
            $errorMsg = curl_error($curl);
            $errorNo = curl_errno($curl);

            throw new \RuntimeException($errorMsg, $errorNo);
        }

        $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        if ((200 > $code || $code >= 300) && $code !== 304) {
            throw new \RuntimeException('Url '.$this->url.' returned invalid code '.$code);
        }

        curl_close($curl);

        return self::getLastResponse($data);
    }
307430
private function send ()
		{
			if (count($this->_params) > 0)
				$this->_options[ CURLOPT_URL ] .= '?' . http_build_query($this->_params);

			if (count($this->_headers) > 0)
				$this->_options[ CURLOPT_HTTPHEADER ] = $this->_headers;

			$curl = curl_init();
			curl_setopt_array($curl, $this->_options);
			$resp = curl_exec($curl);

			if ($resp === false)
			{
				$this->_response = new CurlResponse([
					'status' => CurlResponse::S_SERVERERROR,
					'body'   => 'Error #' . curl_errno($curl) . ': ' . curl_error($curl)
				]);
			}
			else
			{
				$this->_response = new CurlResponse;
				$this->_response->fromCurl($resp, $curl);
			}

			curl_close($curl);

			return $this->_response;
		}
378644
public function send()
    {
        $this->request = $this->client->createRequest(
            $this->method,
            $this->host . $this->resource
        );

        // set headers
        foreach ($this->headers as $header => $value) {
            $this->request->setHeader($header, $value);
        }

        // set body
        if (!empty($this->body)) {
            $this->request->setBody($this->body);
        }

        try {
            // finally send the request
            $this->response = $this->client->send($this->request);
        } catch (RequestException $e) {
            // if the response is an 40x or a 50x then it will throw an exception
            // we catch and get the response stored on the request object
            $this->response = $e->getResponse();
        }

        $this->sent = true;
    }
297292
public function send()
    {
        $buffered_content = $this->returnAllOutputBuffers();
        if (!empty($buffered_content) && is_string($this->content)) {
            $this->content = $buffered_content . $this->content;
        }

        $this->content = $this->output->prepare($this);

        if (!is_string($this->content) && $this->content !== null) {
            $output = get_class($this->output);
            throw new \Parable\Http\Exception("Output class '{$output}' did not result in string or null content.");
        }

        if (!headers_sent()) {
            // @codeCoverageIgnoreStart
            header("{$this->request->getProtocol()} {$this->getHttpCode()} {$this->getHttpCodeText()}");
            header("Content-type: {$this->getContentType()}");
            foreach ($this->getHeaders() as $key => $value) {
                header("{$key}: {$value}");
            }
            // @codeCoverageIgnoreEnd
        }

        if ($this->isHeaderAndFooterContentEnabled()) {
            echo $this->getHeaderContent();
        }

        echo $this->getContent();

        if ($this->isHeaderAndFooterContentEnabled()) {
            echo $this->getFooterContent();
        }

        $this->terminate();
    }
215078
private function sendHeaders()
    {
        if (!array_key_exists('Content-Type', $this->headers)) {
            $this->headers['Content-Type'] = 'text/html; charset=UTF-8';
        }

        $this->headers['Content-Length'] = strlen($this->body);

        header(
            sprintf(
                'HTTP/%s %s %s',
                $this->request->server('SERVER_PROTOCOL'),
                $this->numericStatusCode,
                $this->textualStatusCode ?: $this->statusCode->getText($this->numericStatusCode)
            ),
            true,
            $this->numericStatusCode
        );

        foreach ($this->headers as $key => $value) {
            header(sprintf('%s: %s', $key, $value));
        }
    }
1321174
public function sendHeaders()
    {
        if (!headers_sent()) {
            header(
                sprintf(
                    'HTTP/%s %s %s',
                    $this->getProtocolVersion(),
                    $this->getStatusCode(),
                    ($this->isOk() ? '' : $this->getReasonPhrase())
                ),
                true,
                $this->getStatusCode()
            );

            foreach ($this->header as $name => $value) {
                $name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name)));
                header(sprintf('%s: %s', $name, implode(',', $value)), false, $this->statusCode);
            }

            foreach ($this->cookie as $cookie) {
                header(sprintf('Set-Cookie: %s', $cookie->asString()), false, $this->getStatusCode());
            }
        }
    }
500786
public function send()
    {
        foreach ($this->headers as $header) {
            header($header->getString(), $header->getReplace(), $header->getHttpResponseCode());
        }
    }
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;
    }
765625
public function send()
    {
        $curl = curl_init();

        $this->addParameters()->addHeaders();
        curl_setopt_array($curl, $this->options);
        curl_exec($curl);

        $this->meta = array(
            'info'             => curl_getinfo($curl, CURLINFO_HTTP_CODE),
            'error_message'    => curl_errno($curl),
            'error_code'    => curl_error($curl));

        curl_close($curl);
        unset($curl);

        return $this;
    }
1035846
public function send() {
        header("HTTP/1.0 {$this->code} {$this->get_reason()}");
        foreach ($this->additionalheaders as $header) {
            header($header);
        }
        if (($this->code >= 200) && ($this->code < 300)) {
            if (!empty($this->contenttype)) {
                header("Content-Type: {$this->contenttype};charset=UTF-8");
            }
            if (!empty($this->body)) {
                echo $this->body;
            }
        }
    }
550070
protected function sendRequest()
    {
        $context = stream_context_create($this->request);
        $response = trim(file_get_contents($this->endpoint, FALSE, $context));
        $this->response = new Response($http_response_header, $response, $this->request);

        return $this->response;
    }
1061528
public function sendHeaders()
     {
         if (! headers_sent()) {
             $response = $this->getResponse();
             foreach ($response->getHeaders() as $name => $value) {
                 header($name.': '.$value, false);
             }
             header('HTTP/1.1'.' '.$response->getStatusCode().' '.$response->getStatusMessage());
         }

         return $this;
     }
11064
public function send()
    {
        if ($this->useEncryption && !empty($this->value)) {
            $value = $this->encrypt($this->value);
        } else {
            $value = $this->value;
        }

        setcookie($this->name, $value, $this->expire, $this->path, $this->domain, $this->secure, $this->httpOnly);

        return $this;
    }