From ea4e6e9651c6e9fde49870b9faf88f50e464c5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Sun, 1 Aug 2021 15:16:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Http/HttpHeaders.php | 10 ++++++++++ HttpServer/Http/Request.php | 2 +- System/Core/Xml.php | 3 +-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/HttpServer/Http/HttpHeaders.php b/HttpServer/Http/HttpHeaders.php index a4706c42..40b2182e 100644 --- a/HttpServer/Http/HttpHeaders.php +++ b/HttpServer/Http/HttpHeaders.php @@ -68,6 +68,16 @@ class HttpHeaders return $this; } + + /** + * @param array $headers + */ + public function setHeaders(array $headers) + { + $this->_headers = $headers; + } + + /** * @return array */ diff --git a/HttpServer/Http/Request.php b/HttpServer/Http/Request.php index fd699cf4..6def065b 100644 --- a/HttpServer/Http/Request.php +++ b/HttpServer/Http/Request.php @@ -429,7 +429,7 @@ class Request extends HttpService $httpRequest->fd = $request->fd; $httpRequest->headers = new HttpHeaders(); - $httpRequest->headers->addHeaders(array_merge($request->header, $request->server)); + $httpRequest->headers->setHeaders(array_merge($request->header, $request->server)); $httpRequest->_uri = $httpRequest->headers->get('request_uri'); $httpRequest->_method = $httpRequest->headers->get('request_method'); diff --git a/System/Core/Xml.php b/System/Core/Xml.php index a40beeb7..14d81670 100644 --- a/System/Core/Xml.php +++ b/System/Core/Xml.php @@ -21,13 +21,12 @@ class Xml * @param bool $asArray * @return array|object */ - public static function toArray($data, $asArray = true): object|array + public static function toArray($data, bool $asArray = true): object|array { $data = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); if ($asArray) { return json_decode(json_encode($data), TRUE); } - return json_decode(json_encode($data)); }