This commit is contained in:
as2252258@163.com
2021-08-06 01:01:39 +08:00
parent abe586ff0a
commit e11d8304b7
2 changed files with 21 additions and 32 deletions
-11
View File
@@ -133,7 +133,6 @@ trait HttpParams
} }
/** /**
* @param $name * @param $name
* @param null $defaultValue * @param null $defaultValue
@@ -383,15 +382,5 @@ trait HttpParams
} }
/**
* @param $name
* @return mixed
*/
public function __get($name): mixed
{
$load = $this->load();
return $load[$name] ?? null;
}
} }
+21 -21
View File
@@ -36,13 +36,15 @@ class Request extends HttpService implements RequestInterface
use HttpHeaders, HttpParams; use HttpHeaders, HttpParams;
public int $fd = 0; private array $_explode = [];
private string $_uri = '';
private int $fd = 0;
public bool $isCli = FALSE; private bool $isCli = FALSE;
public float $startTime; private float $startTime;
public int $statusCode = 200; private int $statusCode = 200;
private int $_clientId = 0; private int $_clientId = 0;
@@ -101,7 +103,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function getStartTime(): mixed public function getStartTime(): mixed
{ {
return $this->headers->get('request_time_float'); return $this->getHeader('request_time_float');
} }
@@ -119,7 +121,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function isFavicon(): bool public function isFavicon(): bool
{ {
return $this->headers->getRequestUri() === 'favicon.ico'; return $this->getRequestUri() === 'favicon.ico';
} }
/** /**
@@ -135,7 +137,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function isHead(): bool public function isHead(): bool
{ {
$result = $this->headers->getRequestMethod() == 'HEAD'; $result = $this->getRequestMethod() == 'HEAD';
if ($result) { if ($result) {
$this->setStatus(101); $this->setStatus(101);
} else { } else {
@@ -166,7 +168,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function getIsPackage(): bool public function getIsPackage(): bool
{ {
return $this->headers->getRequestMethod() == 'package'; return $this->getRequestMethod() == 'package';
} }
/** /**
@@ -174,7 +176,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function getIsReceive(): bool public function getIsReceive(): bool
{ {
return $this->headers->getRequestMethod() == 'receive'; return $this->getRequestMethod() == 'receive';
} }
@@ -230,7 +232,7 @@ class Request extends HttpService implements RequestInterface
return $this->_platform; return $this->_platform;
} }
$user = $this->headers->getAgent(); $user = $this->getAgent();
$match = preg_match('/\(.*\)?/', $user, $output); $match = preg_match('/\(.*\)?/', $user, $output);
if (!$match || count($output) < 1) { if (!$match || count($output) < 1) {
return $this->_platform = 'unknown'; return $this->_platform = 'unknown';
@@ -286,7 +288,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function getIsPost(): bool public function getIsPost(): bool
{ {
return $this->headers->getRequestMethod() == 'POST'; return $this->getRequestMethod() == 'POST';
} }
/** /**
@@ -303,7 +305,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function getIsOption(): bool public function getIsOption(): bool
{ {
return $this->headers->getRequestMethod() == 'OPTIONS'; return $this->getRequestMethod() == 'OPTIONS';
} }
/** /**
@@ -311,7 +313,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function getIsGet(): bool public function getIsGet(): bool
{ {
return $this->headers->getRequestMethod() == 'GET'; return $this->getRequestMethod() == 'GET';
} }
/** /**
@@ -319,7 +321,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function getIsDelete(): bool public function getIsDelete(): bool
{ {
return $this->headers->getRequestMethod() == 'DELETE'; return $this->getRequestMethod() == 'DELETE';
} }
/** /**
@@ -329,7 +331,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function getMethod(): string public function getMethod(): string
{ {
$method = $this->headers->getRequestMethod(); $method = $this->getRequestMethod();
if (empty($method)) { if (empty($method)) {
return 'GET'; return 'GET';
} }
@@ -366,7 +368,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function getIp(): string|null public function getIp(): string|null
{ {
$headers = $this->headers->getHeaders(); $headers = $this->getHeaders();
if (!empty($headers['remoteip'])) return $headers['remoteip']; if (!empty($headers['remoteip'])) return $headers['remoteip'];
if (!empty($headers['x-forwarded-for'])) return $headers['x-forwarded-for']; if (!empty($headers['x-forwarded-for'])) return $headers['x-forwarded-for'];
if (!empty($headers['request-ip'])) return $headers['request-ip']; if (!empty($headers['request-ip'])) return $headers['request-ip'];
@@ -398,7 +400,7 @@ class Request extends HttpService implements RequestInterface
'[Debug ' . $datetime . '] ', '[Debug ' . $datetime . '] ',
$this->getIp(), $this->getIp(),
$this->getUri(), $this->getUri(),
'`' . $this->headers->getAgent() . '`', '`' . $this->getAgent() . '`',
$this->getRuntime() $this->getRuntime()
]; ];
return implode(' ', $tmp); return implode(' ', $tmp);
@@ -411,7 +413,7 @@ class Request extends HttpService implements RequestInterface
*/ */
public function is($router): bool public function is($router): bool
{ {
return $this->headers->getRequestUri() == $router; return $this->getRequestUri() == $router;
} }
/** /**
@@ -419,12 +421,10 @@ class Request extends HttpService implements RequestInterface
*/ */
public function isNotFound(): bool public function isNotFound(): bool
{ {
return Json::to(404, 'Page ' . $this->headers->getRequestUri() . ' not found.'); return Json::to(404, 'Page ' . $this->getRequestUri() . ' not found.');
} }
private array $_explode = [];
private string $_uri = '';
} }