This commit is contained in:
2020-09-17 19:10:38 +08:00
parent cc80e0ca31
commit c4c5806914
3 changed files with 12 additions and 4 deletions
+4 -1
View File
@@ -109,7 +109,10 @@ class HttpHeaders
*/ */
public function getHeader($name) public function getHeader($name)
{ {
return $this->headers[$name] ?? null; if (!isset($this->headers[$name])) {
return null;
}
return $this->headers[$name];
} }
+6 -2
View File
@@ -321,7 +321,11 @@ class Request extends Application
*/ */
public function getMethod() public function getMethod()
{ {
return strtolower($this->headers->getHeader('request_method')); $method = $this->headers->getHeader('request_method');
if (empty($method)) {
return 'get';
}
return strtolower($method);
} }
/** /**
@@ -428,7 +432,7 @@ class Request extends Application
if (!empty($request->post)) { if (!empty($request->post)) {
$sRequest->params->setPosts($request->post ?? []); $sRequest->params->setPosts($request->post ?? []);
} }
$sRequest->headers = Snowflake::createObject(HttpHeaders::class,[array_merge($request->server, $request->header ?? [])]); $sRequest->headers = Snowflake::createObject(HttpHeaders::class, [array_merge($request->server, $request->header ?? [])]);
return $sRequest; return $sRequest;
} }
+2 -1
View File
@@ -38,13 +38,14 @@ class JSON
*/ */
private static function filter($data) private static function filter($data)
{ {
array_walk_recursive($data, function (&$value, $key) { array_walk_recursive($data, function ($value, $key) use ($data) {
if (!is_numeric($value)) { if (!is_numeric($value)) {
return; return;
} }
if (is_int(+$value)) { if (is_int(+$value)) {
$value = +$value; $value = +$value;
} }
$data[$key] = $value;
}); });
return json_encode($data, JSON_UNESCAPED_UNICODE); return json_encode($data, JSON_UNESCAPED_UNICODE);
} }