minimalistic-server 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +19 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as http from 'node:http';
|
|
2
2
|
import * as querystring from "node:querystring";
|
|
3
3
|
import * as fs from "node:fs/promises";
|
|
4
|
+
import * as tls from "node:tls";
|
|
4
5
|
|
|
5
6
|
const servers = new Map();
|
|
6
7
|
const keepAliveTimeout = 20000;
|
|
@@ -794,6 +795,24 @@ export class Request {
|
|
|
794
795
|
return this.#headers;
|
|
795
796
|
}
|
|
796
797
|
|
|
798
|
+
getPort() {
|
|
799
|
+
return this.#request.socket.address().port;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
getProtocol() {
|
|
803
|
+
const socket = this.#request.socket;
|
|
804
|
+
|
|
805
|
+
if (socket instanceof tls.TLSSocket && socket.encrypted) {
|
|
806
|
+
return 'https';
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
return 'http';
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
getHost() {
|
|
813
|
+
return this.#request.headers.host;
|
|
814
|
+
}
|
|
815
|
+
|
|
797
816
|
getPath() {
|
|
798
817
|
return this.#path;
|
|
799
818
|
}
|