src/http/Response.php
public function toString ()
	{
		$this->setHeader('Server', sprintf('%s/%s %s.%s.%s', Core::SERVER_SOFT_NAME, Core::SERVER_SOFT_VERSION_NAME, Core::SERVER_SOFT_VERSION, Core::SERVER_SOFT_MINOR_VERSION, Core::SERVER_SOFT_BUILD_VERSION));

		if (!isset($this->head['Cache-Control'])) {
			$this->setHeader('Cache-Control', 'no-cache');
		}
		if (!isset($this->head['Connection'])) {
			$this->setHeader('Connection', 'Keep-Alive');
		}

		if ($this->bodyIsNull() && in_array((int)$this->status_code, $this->HTTP_HEADERS) && (int)$this->status_code != 200) {
			$this->setBody($this->HTTP_HEADERS[ $this->status_code ]);
		}

		if (is_array($this->body)) {
			$this->setHeader('Content-Type', 'application/json');
			$this->body = json_encode($this->body, 256);
		}

		if (!isset($this->head['Content-Type'])) {
			$this->setContentType('html');
		}

		if (!isset($this->head['Content-Length'])) {
			$this->setHeader('Content-Length', strlen($this->body));
		}

		if (is_array($this->head)) {
			foreach ($this->head as $key => $val) {
				$head [] = "{$key}: {$val}";
			}
		}

		$head[] = 'Date: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT';;

		if ($this->serv->session) {
			$this->setCookie('SFMBSESSION', $this->request->getSessionId());
		}

		$cookie = [];
		if (!empty($this->cookie) and is_array($this->cookie)) {
			foreach ($this->cookie as $v) {
				$cookie[] = "Set-Cookie: $v";
			}
		}

		$head = join("\r\n", array_merge($head, $cookie));

		$responseBody
			= <<<CONTEXT
$this->http_protocol {$this->HTTP_HEADERS[$this->status_code]}
$head

$this->body
CONTEXT;

		return $responseBody;

	}
public function toString ()
	{
		$this->setHeader('Server', sprintf('%s/%s %s.%s.%s', Core::SERVER_SOFT_NAME, Core::SERVER_SOFT_VERSION_NAME, Core::SERVER_SOFT_VERSION, Core::SERVER_SOFT_MINOR_VERSION, Core::SERVER_SOFT_BUILD_VERSION));

		if (!isset($this->head['Cache-Control'])) {
			$this->setHeader('Cache-Control', 'no-cache');
		}
		if (!isset($this->head['Connection'])) {
			$this->setHeader('Connection', 'Keep-Alive');
		}

		if ($this->bodyIsNull() && in_array((int)$this->status_code, $this->HTTP_HEADERS) && (int)$this->status_code != 200) {
			$this->setBody($this->HTTP_HEADERS[ $this->status_code ]);
		}

		if (is_array($this->body)) {
			$this->setHeader('Content-Type', 'application/json');
			$this->body = json_encode($this->body, 256);
		}

		if (!isset($this->head['Content-Type'])) {
			$this->setContentType('html');
		}

		if (!isset($this->head['Content-Length'])) {
			$this->setHeader('Content-Length', strlen($this->body));
		}

		if (is_array($this->head)) {
			foreach ($this->head as $key => $val) {
				$head [] = "{$key}: {$val}";
			}
		}

		$head[] = 'Date: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT';;

		if ($this->serv->session) {
			$this->setCookie('SFMBSESSION', $this->request->getSessionId());
		}

		$cookie = [];
		if (!empty($this->cookie) and is_array($this->cookie)) {
			foreach ($this->cookie as $v) {
				$cookie[] = "Set-Cookie: $v";
			}
		}

		$head = join("\r\n", array_merge($head, $cookie));

		$responseBody
			= <<<CONTEXT
$this->http_protocol {$this->HTTP_HEADERS[$this->status_code]}
$head

$this->body
CONTEXT;

		return $responseBody;

	}
自定义tcp_http 使用

@return string