Send headers and body to the client.

@throws RuntimeException
328712
public function sendResponse(ResponseInterface $response): void
    {
        // Send all the headers
        \http_response_code($response->getStatusCode());
        foreach ($response->getHeaders() as $headerName => $headerValues) {
            /** @var string[] $headerValues */
            foreach ($headerValues as $headerValue) {
                \header("$headerName: $headerValue", false);
            }
        }

        // Get the body, rewind it if possible
        $body = $response->getBody();
        if ($body->isSeekable()) {
            $body->rewind();
        }

        // If the body is not readable do not send any body to the client
        if (!$body->isReadable()) {
            return;
        }

        // Send the body (by chunk if specified in the container using streamReadLength value)
        if (null === $this->streamReadLength) {
            echo $body->__toString();

            return;
        }

        while (!$body->eof()) {
            echo $body->read($this->streamReadLength);
        }
    }
13085
public function sendAllHeaders()
    {
        if ($this->status_header !== null) {
            header($this->status_header);
        }

        foreach ($this->headers as $name => $value) {
            header($name . ': ' . $value);
        }
    }
365763
public function send()
    {
        $this->sendCookies();

        $this->sendHeaders();

        if ($this->request->server('REQUEST_METHOD') === 'HEAD') {
            return '';
        }

        echo $this->body;
    }
579335
public function send()
    {
        header(
            sprintf(
                'HTTP/1.1 %s %s',
                $this->statusCode,
                self::codeToReason($this->statusCode)
            )
        );
        foreach ($this->headers as $k => $v) {
            header(
                sprintf('%s: %s', $k, $v)
            );
        }
        echo $this->body;
    }
289801
function send()
    {
        if (!headers_sent()) {
            extract($this->toArray());
            setcookie($name, $value, $expires, $path, $domain, $secure, $httponly);
        }
    }
873457
public void send(HeadersAmp headers,
                   String to, 
                   String methodName,
                   Object ...args)
    throws IOException
  {
    if (log.isLoggable(Level.FINEST)) {
      log.finest(this + " send " + methodName + Arrays.asList(args)
                + "\n  {to:" + to + "," + headers + "}");
    }
    
    try {
      JsonWriterImpl jOut = _jOut;

      jOut.init();

      jOut.writeStartArray();
      jOut.write("send");

      writeHeaders(jOut, headers);

      jOut.write(to);
      jOut.write(methodName);

      writeArgs(jOut, args);

      jOut.writeEndArray();

      jOut.close();
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
      
      throw e;
    }
  }
1070186
public function send(): void
    {
        $body = $this->getBody();

        $this->sendCookies();

        switch (true) {
            case 'CLI' === $this->type:
                // no CLI response
                return;
            case null === $body:
            case StatusCode::NO_CONTENT === $this->getStatusCode():
                $response = new EmptyResponse($this->getStatusCode(), $this->getHeaders());
                break;
            case StatusCode::MOVED_PERMANENTLY === $this->getStatusCode():
            case StatusCode::FOUND === $this->getStatusCode():
                $response = new RedirectResponse(
                    $this->getHeader('Location'),
                    $this->getStatusCode(),
                    $this->getHeaders()
                );
                break;
            case 'JSON' === $this->type:
                // JSON response
                // setup messages
                if (Messages::count()) {
                    $this->setHeader('Bluz-Notify', json_encode(Messages::popAll()));
                }

                // encode body data to JSON
                $response = new JsonResponse(
                    $body,
                    $this->getStatusCode(),
                    $this->getHeaders()
                );
                break;
            case 'FILE' === $this->type:
                // File attachment
                $response = new AttachmentResponse(
                    $this->body->getData()->get('FILE'),
                    $this->getStatusCode(),
                    $this->getHeaders()
                );
                break;
            case 'HTML' === $this->type:
            default:
                // HTML response
                $response = new HtmlResponse(
                    (string)$body,
                    $this->getStatusCode(),
                    $this->getHeaders()
                );
                break;
        }

        $emitter = new SapiEmitter();
        $emitter->emit($response);
    }
322374
public void sendData() throws IOException {
        if (writer != null) {
            writer.write(buffer.toString());
            writer.flush();
            buffer = new StringBuilder();
        }
    }
495424
public function sendHeaders(): void
    {
        foreach ((array) $this->headers as $name => $value) {
            $this->sendHeader($name, $value);
        }
    }
527393
def send(self, url, data, headers):
        
        eventlet.spawn(self._send_payload, (url, data, headers))
284770
public void sendResponse(HttpResponse resp, boolean close) throws IOException {
		StringBuilder header = new StringBuilder();
		header.append("HTTP/1.1").append(' ').append(resp.getStatus().getCode()).append(' ').append(resp.getStatus());
		header.append('\r').append('\n');
		// Set the content type header if it's not already set
		if (!resp.getHeaders().containsKey(HttpHeader.CONTENT_TYPE)) {
			resp.addHeader(HttpHeader.CONTENT_TYPE, "text/html; charset=utf-8");
		}
		// Set the content length header if it's not already set
		if (!resp.getHeaders().containsKey(HttpHeader.CONTENT_LENGTH)) {
			resp.addHeader(HttpHeader.CONTENT_LENGTH, resp.getResponseLength());
		}
		// Copy in the headers
		for (Entry<String, List<Object>> entry : resp.getHeaders().entrySet()) {
			String headerName = HttpUtil.capitalizeHeader(entry.getKey());
			for (Object o : entry.getValue()) {
				header.append(headerName);
				header.append(':').append(' ');
				header.append(o);
				header.append('\r').append('\n');
			}
		}
		header.append('\r').append('\n');
		// Write the header
		output.write(header.toString().getBytes("UTF-8"));

		// Ignore the body for headers and no content
		if (request != null && request.getMethod() == HttpMethod.HEAD || resp.getStatus() == HttpStatus.NO_CONTENT) {
			if (resp.getResponse() instanceof InputStream) {
				((InputStream) resp.getResponse()).close();
			}
		} else {
			// Responses can be InputStreams or Strings
			if (resp.getResponse() instanceof InputStream) {
				// InputStreams will block the session thread (No big deal) and send
				// data without loading it into memory
				InputStream res = resp.getResponse();
				try {
					long remaining = resp.getResponseLength();
					// Write the body
					byte[] buffer = new byte[1024];
					while (remaining > 0) {
						int read = res.read(buffer, 0, remaining > buffer.length ? buffer.length : (int) remaining);
						if (read == -1) {
							break;
						}

						output.write(buffer, 0, read);

						remaining -= read;
					}
				} finally {
					res.close();
				}
			} else if (resp.getResponse() instanceof String) {
				String responseString = resp.getResponse();
				output.write(responseString.getBytes("UTF-8"));
			} else if (resp.getResponse() instanceof byte[]) {
				output.write((byte[]) resp.getResponse());
			}
		}
		// Close it if required.
		if (close) {
			socket.close();
		}
	}

	/**
	 * Send an HttpStatus
	 *
	 * @param status The status to send
	 * @throws IOException If an error occurred while sending
	 */
	public void sendError(HttpStatus status) throws IOException {
		sendResponse(new HttpResponse(status, status.toString()));
	}

	/**
	 * Send an HttpStatus with the specified error message
	 *
	 * @param status The status to send
	 * @param message The error message to send
	 * @throws IOException If an error occurred while sending
	 */
	public void sendError(HttpStatus status, String message) throws IOException {
		sendResponse(new HttpResponse(status, status.toString() + ':' + message));
	}

	/**
	 * Get the remote address from this session
	 *
	 * @return The remote address
	 */
	public InetSocketAddress getRemoteAddress() {
		return (InetSocketAddress) socket.getRemoteSocketAddress();
	}
}
877996
public function Send () {
		if ($this->IsSent()) return;
		$httpVersion = $this->GetHttpVersion();
		$code = $this->GetCode();
		$status = $this->codeMessage !== NULL
			? ' '.$this->codeMessage
			: (isset(static::$codeMessages[$code]) 
				? ' '.static::$codeMessages[$code] 
				: '');
		if (!isset($this->headers['Content-Encoding'])) {
			if (!$this->encoding) $this->encoding = 'utf-8';
			$this->headers['Content-Encoding'] = $this->encoding;
		}
		$this->UpdateHeaders();
		header($httpVersion . ' ' . $code . $status);
		header('Host: ' . $this->request->GetHost());
		foreach ($this->headers as $name => $value) {
			if ($name == 'Content-Type') {
				$charsetMatched = FALSE;
				$charsetPos = strpos($value, 'charset');
				if ($charsetPos !== FALSE) {
					$equalPos = strpos($value, '=', $charsetPos);
					if ($equalPos !== FALSE) $charsetMatched = TRUE;
				}
				if (!$charsetMatched) $value .= ';charset=' . $this->encoding;
			}
			if (isset($this->disabledHeaders[$name])) {
				header_remove($name);
			} else {
				header($name . ": " . $value);
			}
		}
		foreach ($this->disabledHeaders as $name => $b)
			header_remove($name);
		$this->addTimeAndMemoryHeader();
		echo $this->body;
		if (ob_get_level()) echo ob_get_clean();
		flush();
		$this->sent = TRUE;
	}
804976
private void sendSomeRequests() {
		ResponseListener responseListener = new MyResponseListener();

		sendCustomUrlRequest(responseListener);
		sendAutoRetryRequest(responseListener);
		downloadImage(responseListener);
		uploadData(responseListener);
		uploadFile(responseListener);
		uploadText(responseListener);
	}
1248439
public function send()
    {
        $this->sendHeaders();
        $this->sendCookies();

        if (ResponseCode::canHaveBody($this->statusCode)) {
            $this->sendBody();
        }
    }
542542
private function sendHeaders()
    {
        $this->useCookies();
        $this->setProtocolAndCode();
        header(
            sprintf(
                "Content-Type: %s; charset=%s",
                $this->getContentType(),
                $this->getCharset()
            )
        );

        if (count($this->getHeaders())) {
            foreach ($this->getHeaders() as $header) {

                header($header);
            }
        }
    }
797852
protected function sendHeaders()
    {
        header(sprintf('%s %s', self::PROTOCOL_VERSION, ResponseCode::getMessageForCode($this->statusCode)));

        foreach ($this->headers as $name => $value) {
            header(sprintf("%s: %s", $name, $value));
        }
    }
139363
public function sendHeaders()
    {
        foreach ($this->headers as $args) {
            $func = array_shift($args);
            call_user_func_array($func, $args);
        }
    }