改名
This commit is contained in:
@@ -215,18 +215,13 @@ class Response extends HttpService
|
|||||||
/**
|
/**
|
||||||
* @param $sendData
|
* @param $sendData
|
||||||
* @param $status
|
* @param $status
|
||||||
* @return mixed
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function sendData($sendData, $status): mixed
|
private function sendData($sendData, $status): string
|
||||||
{
|
{
|
||||||
$this->response->status($status);
|
$sendData = $this->setHeaders($status, $sendData);
|
||||||
$this->response->header('Content-Type', $this->getContentType());
|
|
||||||
$this->response->header('Run-Time', $this->getRuntime());
|
$this->response->end($sendData);
|
||||||
if (!empty($sendData)) {
|
|
||||||
$this->response->end($this->headers($sendData));
|
|
||||||
} else {
|
|
||||||
$this->response->end();
|
|
||||||
}
|
|
||||||
$this->response = null;
|
$this->response = null;
|
||||||
unset($this->response);
|
unset($this->response);
|
||||||
return $sendData;
|
return $sendData;
|
||||||
@@ -234,18 +229,22 @@ class Response extends HttpService
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param $status
|
||||||
* @param $sendData
|
* @param $sendData
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function headers($sendData): string
|
private function setHeaders($status, $sendData): string
|
||||||
{
|
{
|
||||||
if (!empty($this->headers) && is_array($this->headers)) {
|
$this->response->status($status);
|
||||||
var_dump($this->headers);
|
$this->response->header('Content-Type', $this->getContentType());
|
||||||
|
$this->response->header('Run-Time', $this->getRuntime());
|
||||||
|
|
||||||
|
if (empty($this->headers) || !is_array($this->headers)) {
|
||||||
|
return $sendData == null ? '' : $sendData;
|
||||||
|
}
|
||||||
foreach ($this->headers as $key => $header) {
|
foreach ($this->headers as $key => $header) {
|
||||||
$this->response->header($key, $header, true);
|
$this->response->header($key, $header, true);
|
||||||
}
|
}
|
||||||
$this->headers = [];
|
|
||||||
}
|
|
||||||
return $sendData == null ? '' : $sendData;
|
return $sendData == null ? '' : $sendData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user