改名
This commit is contained in:
@@ -210,32 +210,40 @@ class Response extends Application
|
|||||||
* @param $status
|
* @param $status
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private function sendData($sendData, $status)
|
private function sendData($sendData, $status): mixed
|
||||||
{
|
{
|
||||||
$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());
|
||||||
|
$this->response->end($this->headers($sendData));
|
||||||
|
$this->response = null;
|
||||||
|
unset($this->response);
|
||||||
|
return $sendData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $sendData
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function headers($sendData): string
|
||||||
|
{
|
||||||
if (!empty($this->headers) && is_array($this->headers)) {
|
if (!empty($this->headers) && is_array($this->headers)) {
|
||||||
foreach ($this->headers as $key => $header) {
|
foreach ($this->headers as $key => $header) {
|
||||||
$this->response->header($key, $header);
|
$this->response->header($key, $header);
|
||||||
}
|
}
|
||||||
$this->headers = [];
|
$this->headers = [];
|
||||||
}
|
}
|
||||||
if (empty($sendData)) {
|
return $sendData == null ? '' : $sendData;
|
||||||
$sendData = '';
|
|
||||||
}
|
|
||||||
$this->response->end($sendData);
|
|
||||||
$this->response = null;
|
|
||||||
unset($this->response);
|
|
||||||
return $sendData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $url
|
* @param $url
|
||||||
* @param array $param
|
* @param array $param
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function redirect($url, array $param = [])
|
public function redirect($url, array $param = []): int
|
||||||
{
|
{
|
||||||
if (!empty($param)) {
|
if (!empty($param)) {
|
||||||
$url .= '?' . http_build_query($param);
|
$url .= '?' . http_build_query($param);
|
||||||
@@ -251,7 +259,7 @@ class Response extends Application
|
|||||||
* @param null $response
|
* @param null $response
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function create($response = null)
|
public static function create($response = null): mixed
|
||||||
{
|
{
|
||||||
$ciResponse = Context::setContext('response', new Response());
|
$ciResponse = Context::setContext('response', new Response());
|
||||||
$ciResponse->response = $response;
|
$ciResponse->response = $response;
|
||||||
@@ -273,7 +281,7 @@ class Response extends Application
|
|||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getRuntime()
|
public function getRuntime(): string
|
||||||
{
|
{
|
||||||
return sprintf('%.5f', microtime(TRUE) - $this->startTime);
|
return sprintf('%.5f', microtime(TRUE) - $this->startTime);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user