From 0a6ab87528a5bd887eeefa500b80f516fe8bf6e2 Mon Sep 17 00:00:00 2001
From: Anton Piliugin <anton.piliugin@icloud.com>
Date: Fri, 17 Jun 2022 10:05:45 +0500
Subject: [PATCH] Refactoring

---
 node_modules/uWebSockets.js/package.json |  7 +++----
 package-lock.json                        |  2 +-
 package.json                             |  2 +-
 src/Request.js                           | 16 +++++++---------
 4 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/node_modules/uWebSockets.js/package.json b/node_modules/uWebSockets.js/package.json
index 67c5ca7..99d6990 100644
--- a/node_modules/uWebSockets.js/package.json
+++ b/node_modules/uWebSockets.js/package.json
@@ -7,19 +7,18 @@
   "_phantomChildren": {},
   "_requested": {
     "type": "git",
-    "raw": "uWebSockets.js@github:uNetworking/uWebSockets.js#v20.10.0",
-    "name": "uWebSockets.js",
-    "escapedName": "uWebSockets.js",
+    "raw": "github:uNetworking/uWebSockets.js#v20.10.0",
     "rawSpec": "github:uNetworking/uWebSockets.js#v20.10.0",
     "saveSpec": "github:uNetworking/uWebSockets.js#v20.10.0",
     "fetchSpec": null,
     "gitCommittish": "v20.10.0"
   },
   "_requiredBy": [
+    "#USER",
     "/"
   ],
   "_resolved": "github:uNetworking/uWebSockets.js#806df48c9da86af7b3341f3e443388c7cd15c3de",
-  "_spec": "uWebSockets.js@github:uNetworking/uWebSockets.js#v20.10.0",
+  "_spec": "github:uNetworking/uWebSockets.js#v20.10.0",
   "_where": "/home/anton/Documents/uQuik",
   "bundleDependencies": false,
   "deprecated": false,
diff --git a/package-lock.json b/package-lock.json
index f5eb63a..4d07fea 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "uquik",
-  "version": "1.0.24",
+  "version": "1.0.25",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
diff --git a/package.json b/package.json
index 7e28a35..f872471 100644
--- a/package.json
+++ b/package.json
@@ -44,4 +44,4 @@
     "eslint-plugin-promise": "^6.0.0",
     "nanobench": "^2.1.1"
   }
-}
\ No newline at end of file
+}
diff --git a/src/Request.js b/src/Request.js
index 555c536..1009de2 100644
--- a/src/Request.js
+++ b/src/Request.js
@@ -619,7 +619,7 @@ class Request extends Readable {
     if (this.remote_ip) return this.remote_ip
 
     if (this.app_options.get('trust_proxy')) {
-      const xForwardedFor = this.get('x-forwarded-for')
+      const xForwardedFor = this.headers.get('x-forwarded-for')
       if (xForwardedFor) return (this.remote_ip = xForwardedFor.split(',')[0])
     }
 
@@ -635,7 +635,7 @@ class Request extends Readable {
     if (this.remote_proxy_ip) return this.remote_proxy_ip
 
     if (this.app_options.get('trust_proxy')) {
-      const xForwardedFor = this.get('x-forwarded-for')
+      const xForwardedFor = this.headers.get('x-forwarded-for')
       if (xForwardedFor && xForwardedFor.indexOf(',') !== -1) return (this.remote_proxy_ip = xForwardedFor.split(',')[1])
     }
 
@@ -685,7 +685,7 @@ class Request extends Readable {
   get protocol () {
     // Resolves x-forwarded-proto header if trust proxy is enabled
     const trustProxy = this.app_options.get('trust_proxy')
-    const xForwardedProto = this.get('x-forwarded-proto')
+    const xForwardedProto = this.headers.get('x-forwarded-proto')
     if (trustProxy && xForwardedProto) return xForwardedProto.indexOf(',') !== -1 ? xForwardedProto.split(',')[0] : xForwardedProto
 
     // Use uWS initially defined protocol
@@ -705,13 +705,11 @@ class Request extends Readable {
      * @returns {Array}
      */
   get ips () {
-    const clientIP = this.ip
-    const proxyIP = this.proxy_ip
     const trustProxy = this.app_options.get('trust_proxy')
-    const xForwardedFor = this.get('x-forwarded-for')
+    const xForwardedFor = this.headers.get('x-forwarded-for')
     if (trustProxy && xForwardedFor) return xForwardedFor.split(',')
 
-    return [clientIP, proxyIP]
+    return [this.ip, this.proxy_ip]
   }
 
   /**
@@ -719,10 +717,10 @@ class Request extends Readable {
      */
   get hostname () {
     const trustProxy = this.app_options.get('trust_proxy')
-    let host = this.get('x-forwarded-host')
+    let host = this.headers.get('x-forwarded-host')
 
     if (!host || !trustProxy) {
-      host = this.get('host')
+      host = this.headers.get('host')
     } else if (host.indexOf(',') !== -1) {
       // Note: X-Forwarded-Host is normally only ever a
       //       single value, but this is to be safe.