This commit is contained in:
2020-09-17 14:26:38 +08:00
parent fbec7dddc8
commit 28a920841a
+9 -4
View File
@@ -98,13 +98,12 @@ class Response extends Application
/** /**
* @param $key * @param $key
* @param $value * @param $value
* @return Response
*/ */
public function addHeader($key, $value) public function addHeader($key, $value)
{ {
if ($this->isClient()) { $this->headers[$key] = $value;
return; return $this;
}
$this->response->header($key, $value);
} }
/** /**
@@ -184,6 +183,12 @@ class Response extends Application
$this->response->status($status); $this->response->status($status);
$this->response->header('Content-Type', $this->getContentType()); $this->response->header('Content-Type', $this->getContentType());
$this->response->header('Run-Time', $this->getRuntime()); $this->response->header('Run-Time', $this->getRuntime());
if (!empty($this->headers)) {
foreach ($this->headers as $key => $header) {
$this->response->header($key, $header);
}
$this->headers = [];
}
if (empty($sendData)) { if (empty($sendData)) {
$sendData = ''; $sendData = '';
} }