说明
前面所有分析,都是从 $response = $http->run(); 展开的,经历了漫漫长路,run 方法终于运行完毕,返回一个 Response 对象,程序又回到入口文件:
.
.
.
$response = $http->run();
$response->send();
$http->end($response);
接下来是执行 $response->send();
。send
方法:
public function send(): void
{
// 处理输出数据
$data = $this->getContent();
// 如果还沒有发送响应头且$this->header不为空
if (!headers_sent() && !empty($this->header)) {
// 发送状态码
http_response_code($this->