/* SEND
Send headers & Output tris content
761362
public function send()
    {
        if ($this->mode == 'pro') {
            ob_end_clean();
            ob_start('ob_gzhandler');
        }
        header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT');
        header('Cache-Control: must_revalidate, public, max-age=31536000');
        header('X-Server: Qzumba/0.1.8.beta');//for safety ...
        header('X-Powered-By: NEOS PHP FRAMEWORK/1.3.0');//for safety ...

        if ($this->cached &&
        file_exists($this->pathHtmlCache.$this->name.'_cache.html')) {
            return $this->sendWithCach();
        } else {
            //$timer = £TIME.' - '.microtime(true).' = '.round((microtime(true)-£TIME)*1000, 2).'ms';
            exit(eval('?>'.$this->content));
        }
    }
46223
protected function sendContent()
    {
        $body = $this->getBody();
        if (!$body->isReadable()) {
            throw new \RuntimeException('Unable to send content: body stream is not readable.');
        }

        set_time_limit(0); // Reset time limit for big files
        $chunkSize = 8 * 1024 * 1024; // 8MB per chunk

        if (is_array($this->bodyRange)) {
            [$begin, $end] = $this->bodyRange;

            if (!$body->isSeekable()) {
                throw new \RuntimeException('Unable to send content in range: body stream is not seekable.');
            }

            $body->seek($begin);
            while (!$body->eof() && ($pos = $body->tell()) <= $end) {
                if ($pos + $chunkSize > $end) {
                    $chunkSize = $end - $pos + 1;
                }
                echo $body->read($chunkSize);
                flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
            }
            $body->close();
        } else {
            if ($body->isSeekable()) {
                $body->seek(0);
            }
            while (!$body->eof()) {
                echo $body->read($chunkSize);
                flush(); // Free up memory. Otherwise large files will trigger PHP's memory limit.
            }
            $body->close();
            return;
        }
    }
1106628
public function send(SimpleHeaders $headers = null, $die_after = true)
    {
        if ($headers === null) {
            $headers = $this->getHttpHeaders();
        }

        ob_end_clean();

        try {
            $data = $this->getData();
        } catch (\Exception $e) {
            throw $e;
        }
        $headers->outputHeaders($replace = true);
        echo $data;
        if ($die_after) {
            die();
        }
    }
796244
public function send()
    {
        $this->sendHeader();

        $body = $this->getBody();

        $body->rewind();

        echo $body->getContents();
    }
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();
		}
	}
500786
public function send()
    {
        foreach ($this->headers as $header) {
            header($header->getString(), $header->getReplace(), $header->getHttpResponseCode());
        }
    }
994434
public function send()
    {
        if ( ! headers_sent()) {
            $this->sendHeaders();
        }
        http_response_code($this->status);
        echo $this->prepareContent($this->content);
    }
1374295
def send_chunk(type, content = nil)
      chunk = Chunk.new(type, content).to_s
      socket.write chunk
    end
402127
def _send_packet(self, packet):
        """"""
        encoded = json.dumps(packet)
        self.ws.send(encoded)
129796
public function sendHeaders()
    {
        if (!$this->headersAreSent()) {
            header(
                sprintf(
                    'HTTP/%s %s %s',
                    $this->httpVersion,
                    $this->statusCode,
                    $this->statusText
                ),
                true,
                $this->statusCode
            );

            // Send the headers
            foreach ($this->headers->getAll() as $name => $values) {
                // Headers are allowed to have multiple values
                foreach ($values as $value) {
                    header("$name:$value", false, $this->statusCode);
                }
            }

            // Send the cookies
            /** @var Cookie $cookie */
            foreach ($this->headers->getCookies(true) as $cookie) {
                setcookie(
                    $cookie->getName(),
                    $cookie->getValue(),
                    $cookie->getExpiration(),
                    $cookie->getPath(),
                    $cookie->getDomain(),
                    $cookie->isSecure(),
                    $cookie->isHttpOnly()
                );
            }
        }
    }
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;
    }
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());
            }
        }
    }
416524
public function send()
    {
        header($this->getStatusStr());

        foreach($this->headers as $header => $value) {
            header(sprintf("%s: %s", $header, implode(',', $value)));
        }

        $body = $this->getBody();

        if ($body->isAttached()) {
            $body->rewind();
            while (!$body->eof()) {
                echo $body->read($this->bodySize);
            }
        }
    }
336295
public void send(OutputStream os, 
                   HeadersAmp headers,
                   String address, 
                   String methodName,
                   PodRef podCaller,
                   Object []args)
    throws IOException
  {
    init(os);

    OutH3 out = _out;

    if (out == null) {
      return;
    }
    
    if (log.isLoggable(Level.FINEST)) {
      log.finest("hamp-send-w " + methodName + Arrays.asList(args)
                + "\n  {to:" + address + "}");
    }
  
    try {
      out.writeLong(MessageTypeHamp.SEND.ordinal());
      writeHeaders(out, headers);
    
      writeMethod(out, address, methodName, podCaller);
      writeArgs(out, args);

      // XXX: out.flushBuffer();
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
      
      throw e;
    }
  }
416779
public function sendHeaders(): void
	{
		// Send status header

		$protocol = $this->request->getServer()->get('SERVER_PROTOCOL', 'HTTP/1.1');

		header($protocol . ' ' . $this->statusCode . ' ' . $this->statusCodes[$this->statusCode]);

		// Send content type header

		$contentType = $this->contentType;

		if(stripos($contentType, 'text/') === 0 || in_array($contentType, ['application/json', 'application/xml', 'application/rss+xml', 'application/atom+xml']))
		{
			$contentType .= '; charset=' . $this->charset;
		}

		header('Content-Type: ' . $contentType);

		// Send other headers

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

		// Send cookie headers

		foreach($this->cookies->all() as $cookie)
		{
			['raw' => $raw, 'name' => $name, 'value' => $value, 'options' => $options] = $cookie;

			if($raw)
			{
				setrawcookie($name, $value, $options['expires'], $options['path'], $options['domain'], $options['secure'], $options['httponly']);
			}
			else
			{
				setcookie($name, $value, $options['expires'], $options['path'], $options['domain'], $options['secure'], $options['httponly']);
			}
		}
	}
164337
def send_head(self):
        
        path = self.translate_path(self.path)
        f = None
        to_render = False
        if os.path.isdir(path):
            if not self.path.endswith('/'):
                # redirect browser - doing basically what apache does
                self.send_response(301)
                self.send_header("Location", self.path + "/")
                self.end_headers()
                return None
        else:
            # check if URL corresponds to a template to render
            if path.endswith("/"):
                index = path[:-1]
            else:
                index = path
            for ext in '.html', '.htm':
                if os.path.exists(index + ext):
                    to_render = True
                    realpath = index + ext
                    break
        if os.path.isdir(path):
            # if dir, check for existence of index.htm*
            for index in "index.html", "index.htm":
                index = os.path.join(path, index)
                if os.path.exists(index):
                    realpath = index
                    to_render = True
                    break
            else:
                return self.list_directory(path)
        # deny if URL directly requests for *.html file, allow if dir
        file_extension = os.path.splitext(path)[1]
        if file_extension in ('.html', '.htm') and not os.path.isdir(path):
            self.send_error(404, "File not found")
            return None
        if to_render:
            path = realpath
        ctype = self.guess_type(path)
        try:
            f = open(path, 'rb')
        except IOError:
            self.send_error(404, "File not found")
            return None
        fs = os.fstat(f.fileno())
        if to_render:
            stream, length = self.gen_response_stream(f)
        else:
            length = fs[6]
        self.send_response(200)
        self.send_header("Content-type", ctype)
        self.send_header("Content-Length", str(length))
        self.send_header("Last-Modified", self.date_time_string(
            fs.st_mtime))
        self.end_headers()
        if to_render:
            return stream
        return f
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"');
    }