改名
This commit is contained in:
+17
-28
@@ -36,9 +36,9 @@ class Request extends HttpService
|
|||||||
|
|
||||||
public int $fd = 0;
|
public int $fd = 0;
|
||||||
|
|
||||||
public ?HttpParams $params;
|
public ?HttpParams $params = null;
|
||||||
|
|
||||||
public ?HttpHeaders $headers;
|
public ?HttpHeaders $headers = null;
|
||||||
|
|
||||||
public bool $isCli = FALSE;
|
public bool $isCli = FALSE;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ class Request extends HttpService
|
|||||||
|
|
||||||
|
|
||||||
const HTTP_POST = 'post';
|
const HTTP_POST = 'post';
|
||||||
const HTTP_GET = 'get';
|
const HTTP_GET = 'GET';
|
||||||
const HTTP_CMD = 'rpc';
|
const HTTP_CMD = 'rpc';
|
||||||
const HTTP_LISTEN = 'listen';
|
const HTTP_LISTEN = 'listen';
|
||||||
const HTTP_SOCKET = 'sw::socket';
|
const HTTP_SOCKET = 'sw::socket';
|
||||||
@@ -124,7 +124,7 @@ class Request extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function isHead(): bool
|
public function isHead(): bool
|
||||||
{
|
{
|
||||||
$result = $this->headers->getHeader('request_method') == 'head';
|
$result = $this->headers->getHeader('request_method') == 'HEAD';
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->setStatus(101);
|
$this->setStatus(101);
|
||||||
} else {
|
} else {
|
||||||
@@ -222,16 +222,7 @@ class Request extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function getUri(): string
|
public function getUri(): string
|
||||||
{
|
{
|
||||||
if (!$this->headers) {
|
return $this->headers->getHeader('request_uri');
|
||||||
return 'command exec.';
|
|
||||||
}
|
|
||||||
if (!empty($this->uri)) {
|
|
||||||
return $this->uri;
|
|
||||||
}
|
|
||||||
$uri = $this->headers->getHeader('request_uri');
|
|
||||||
$uri = ltrim($uri, '/');
|
|
||||||
if (empty($uri)) return '/';
|
|
||||||
return $uri;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -307,7 +298,7 @@ class Request extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function getIsPost(): bool
|
public function getIsPost(): bool
|
||||||
{
|
{
|
||||||
return $this->getMethod() == 'post';
|
return $this->getMethod() == 'POST';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,7 +315,7 @@ class Request extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function getIsOption(): bool
|
public function getIsOption(): bool
|
||||||
{
|
{
|
||||||
return $this->getMethod() == 'options';
|
return $this->getMethod() == 'OPTIONS';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -332,7 +323,7 @@ class Request extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function getIsGet(): bool
|
public function getIsGet(): bool
|
||||||
{
|
{
|
||||||
return $this->getMethod() == 'get';
|
return $this->getMethod() == 'GET';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,7 +331,7 @@ class Request extends HttpService
|
|||||||
*/
|
*/
|
||||||
public function getIsDelete(): bool
|
public function getIsDelete(): bool
|
||||||
{
|
{
|
||||||
return $this->getMethod() == 'delete';
|
return $this->getMethod() == 'DELETE';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,9 +343,9 @@ class Request extends HttpService
|
|||||||
{
|
{
|
||||||
$method = $this->headers->get('request_method');
|
$method = $this->headers->get('request_method');
|
||||||
if (empty($method)) {
|
if (empty($method)) {
|
||||||
return 'get';
|
return 'GET';
|
||||||
}
|
}
|
||||||
return strtolower($method);
|
return $method;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -456,14 +447,12 @@ class Request extends HttpService
|
|||||||
Context::setContext('request', $request);
|
Context::setContext('request', $request);
|
||||||
/** @var Request $sRequest */
|
/** @var Request $sRequest */
|
||||||
$sRequest = Snowflake::getDi()->get(Request::class);
|
$sRequest = Snowflake::getDi()->get(Request::class);
|
||||||
|
if ($sRequest->headers === null) {
|
||||||
$sRequest->params = di(HttpParams::class);
|
$sRequest->headers = di(HttpHeaders::class);
|
||||||
$sRequest->headers = di(HttpHeaders::class);
|
}
|
||||||
|
if ($sRequest->params === null) {
|
||||||
$sRequest->uri = $sRequest->headers->get('request_uri');
|
$sRequest->params = di(HttpParams::class);
|
||||||
|
}
|
||||||
$sRequest->parseUri();
|
|
||||||
|
|
||||||
return $sRequest;
|
return $sRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user