summaryrefslogtreecommitdiff
path: root/ext/http/00_serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/http/00_serve.js')
-rw-r--r--ext/http/00_serve.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/ext/http/00_serve.js b/ext/http/00_serve.js
index e881cca2a..b51dfee07 100644
--- a/ext/http/00_serve.js
+++ b/ext/http/00_serve.js
@@ -129,6 +129,7 @@ class InnerRequest {
#streamRid;
#body;
#upgraded;
+ #urlValue;
constructor(slabId, context) {
this.#slabId = slabId;
@@ -236,6 +237,10 @@ class InnerRequest {
}
url() {
+ if (this.#urlValue !== undefined) {
+ return this.#urlValue;
+ }
+
if (this.#methodAndUri === undefined) {
if (this.#slabId === undefined) {
throw new TypeError("request closed");
@@ -249,27 +254,28 @@ class InnerRequest {
// * is valid for OPTIONS
if (path === "*") {
- return "*";
+ return this.#urlValue = "*";
}
// If the path is empty, return the authority (valid for CONNECT)
if (path == "") {
- return this.#methodAndUri[1];
+ return this.#urlValue = this.#methodAndUri[1];
}
// CONNECT requires an authority
if (this.#methodAndUri[0] == "CONNECT") {
- return this.#methodAndUri[1];
+ return this.#urlValue = this.#methodAndUri[1];
}
const hostname = this.#methodAndUri[1];
if (hostname) {
// Construct a URL from the scheme, the hostname, and the path
- return this.#context.scheme + hostname + path;
+ return this.#urlValue = this.#context.scheme + hostname + path;
}
// Construct a URL from the scheme, the fallback hostname, and the path
- return this.#context.scheme + this.#context.fallbackHost + path;
+ return this.#urlValue = this.#context.scheme + this.#context.fallbackHost +
+ path;
}
get remoteAddr() {