diff --git a/HttpServer/Http/HttpHeaders.php b/HttpServer/Http/HttpHeaders.php index 6f6305bb..2a63ccf8 100644 --- a/HttpServer/Http/HttpHeaders.php +++ b/HttpServer/Http/HttpHeaders.php @@ -109,7 +109,10 @@ class HttpHeaders */ public function getHeader($name) { - return $this->headers[$name] ?? null; + if (!isset($this->headers[$name])) { + return null; + } + return $this->headers[$name]; } diff --git a/HttpServer/Http/Request.php b/HttpServer/Http/Request.php index 64aba085..cb7a3e37 100644 --- a/HttpServer/Http/Request.php +++ b/HttpServer/Http/Request.php @@ -321,7 +321,11 @@ class Request extends Application */ 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)) { $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; } diff --git a/System/Core/JSON.php b/System/Core/JSON.php index 8b11fa40..0411186e 100644 --- a/System/Core/JSON.php +++ b/System/Core/JSON.php @@ -38,13 +38,14 @@ class JSON */ 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)) { return; } if (is_int(+$value)) { $value = +$value; } + $data[$key] = $value; }); return json_encode($data, JSON_UNESCAPED_UNICODE); }