@hono/node-server 1.4.0 → 1.5.0
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/dist/index.js +18 -5
- package/dist/index.mjs +18 -5
- package/dist/listener.js +18 -5
- package/dist/listener.mjs +18 -5
- package/dist/request.js +18 -5
- package/dist/request.mjs +18 -5
- package/dist/server.js +18 -5
- package/dist/server.mjs +18 -5
- package/dist/vercel.js +18 -5
- package/dist/vercel.mjs +18 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,12 +40,17 @@ module.exports = __toCommonJS(src_exports);
|
|
|
40
40
|
var import_node_http = require("http");
|
|
41
41
|
|
|
42
42
|
// src/request.ts
|
|
43
|
+
var import_node_http2 = require("http2");
|
|
43
44
|
var import_node_stream = require("stream");
|
|
44
45
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
45
46
|
const headerRecord = [];
|
|
46
|
-
const
|
|
47
|
-
for (let i = 0; i <
|
|
48
|
-
|
|
47
|
+
const rawHeaders = incoming.rawHeaders;
|
|
48
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
49
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
50
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
51
|
+
58) {
|
|
52
|
+
headerRecord.push([key, value]);
|
|
53
|
+
}
|
|
49
54
|
}
|
|
50
55
|
const init = {
|
|
51
56
|
method,
|
|
@@ -60,15 +65,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
60
65
|
var getRequestCache = Symbol("getRequestCache");
|
|
61
66
|
var requestCache = Symbol("requestCache");
|
|
62
67
|
var incomingKey = Symbol("incomingKey");
|
|
68
|
+
var urlKey = Symbol("urlKey");
|
|
63
69
|
var requestPrototype = {
|
|
64
70
|
get method() {
|
|
65
71
|
return this[incomingKey].method || "GET";
|
|
66
72
|
},
|
|
67
73
|
get url() {
|
|
68
|
-
return
|
|
74
|
+
return this[urlKey];
|
|
69
75
|
},
|
|
70
76
|
[getRequestCache]() {
|
|
71
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
77
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
78
|
+
this.method,
|
|
79
|
+
this[urlKey],
|
|
80
|
+
this[incomingKey]
|
|
81
|
+
);
|
|
72
82
|
}
|
|
73
83
|
};
|
|
74
84
|
[
|
|
@@ -102,6 +112,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
102
112
|
var newRequest = (incoming) => {
|
|
103
113
|
const req = Object.create(requestPrototype);
|
|
104
114
|
req[incomingKey] = incoming;
|
|
115
|
+
req[urlKey] = new URL(
|
|
116
|
+
`http://${incoming instanceof import_node_http2.Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
117
|
+
).href;
|
|
105
118
|
return req;
|
|
106
119
|
};
|
|
107
120
|
|
package/dist/index.mjs
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
import { createServer as createServerHTTP } from "http";
|
|
3
3
|
|
|
4
4
|
// src/request.ts
|
|
5
|
+
import { Http2ServerRequest } from "http2";
|
|
5
6
|
import { Readable } from "stream";
|
|
6
7
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
7
8
|
const headerRecord = [];
|
|
8
|
-
const
|
|
9
|
-
for (let i = 0; i <
|
|
10
|
-
|
|
9
|
+
const rawHeaders = incoming.rawHeaders;
|
|
10
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
11
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
12
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
13
|
+
58) {
|
|
14
|
+
headerRecord.push([key, value]);
|
|
15
|
+
}
|
|
11
16
|
}
|
|
12
17
|
const init = {
|
|
13
18
|
method,
|
|
@@ -22,15 +27,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
22
27
|
var getRequestCache = Symbol("getRequestCache");
|
|
23
28
|
var requestCache = Symbol("requestCache");
|
|
24
29
|
var incomingKey = Symbol("incomingKey");
|
|
30
|
+
var urlKey = Symbol("urlKey");
|
|
25
31
|
var requestPrototype = {
|
|
26
32
|
get method() {
|
|
27
33
|
return this[incomingKey].method || "GET";
|
|
28
34
|
},
|
|
29
35
|
get url() {
|
|
30
|
-
return
|
|
36
|
+
return this[urlKey];
|
|
31
37
|
},
|
|
32
38
|
[getRequestCache]() {
|
|
33
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
39
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
40
|
+
this.method,
|
|
41
|
+
this[urlKey],
|
|
42
|
+
this[incomingKey]
|
|
43
|
+
);
|
|
34
44
|
}
|
|
35
45
|
};
|
|
36
46
|
[
|
|
@@ -64,6 +74,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
64
74
|
var newRequest = (incoming) => {
|
|
65
75
|
const req = Object.create(requestPrototype);
|
|
66
76
|
req[incomingKey] = incoming;
|
|
77
|
+
req[urlKey] = new URL(
|
|
78
|
+
`http://${incoming instanceof Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
79
|
+
).href;
|
|
67
80
|
return req;
|
|
68
81
|
};
|
|
69
82
|
|
package/dist/listener.js
CHANGED
|
@@ -35,12 +35,17 @@ __export(listener_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(listener_exports);
|
|
36
36
|
|
|
37
37
|
// src/request.ts
|
|
38
|
+
var import_node_http2 = require("http2");
|
|
38
39
|
var import_node_stream = require("stream");
|
|
39
40
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
40
41
|
const headerRecord = [];
|
|
41
|
-
const
|
|
42
|
-
for (let i = 0; i <
|
|
43
|
-
|
|
42
|
+
const rawHeaders = incoming.rawHeaders;
|
|
43
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
44
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
45
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
46
|
+
58) {
|
|
47
|
+
headerRecord.push([key, value]);
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
const init = {
|
|
46
51
|
method,
|
|
@@ -55,15 +60,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
55
60
|
var getRequestCache = Symbol("getRequestCache");
|
|
56
61
|
var requestCache = Symbol("requestCache");
|
|
57
62
|
var incomingKey = Symbol("incomingKey");
|
|
63
|
+
var urlKey = Symbol("urlKey");
|
|
58
64
|
var requestPrototype = {
|
|
59
65
|
get method() {
|
|
60
66
|
return this[incomingKey].method || "GET";
|
|
61
67
|
},
|
|
62
68
|
get url() {
|
|
63
|
-
return
|
|
69
|
+
return this[urlKey];
|
|
64
70
|
},
|
|
65
71
|
[getRequestCache]() {
|
|
66
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
72
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
73
|
+
this.method,
|
|
74
|
+
this[urlKey],
|
|
75
|
+
this[incomingKey]
|
|
76
|
+
);
|
|
67
77
|
}
|
|
68
78
|
};
|
|
69
79
|
[
|
|
@@ -97,6 +107,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
97
107
|
var newRequest = (incoming) => {
|
|
98
108
|
const req = Object.create(requestPrototype);
|
|
99
109
|
req[incomingKey] = incoming;
|
|
110
|
+
req[urlKey] = new URL(
|
|
111
|
+
`http://${incoming instanceof import_node_http2.Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
112
|
+
).href;
|
|
100
113
|
return req;
|
|
101
114
|
};
|
|
102
115
|
|
package/dist/listener.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// src/request.ts
|
|
2
|
+
import { Http2ServerRequest } from "http2";
|
|
2
3
|
import { Readable } from "stream";
|
|
3
4
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
4
5
|
const headerRecord = [];
|
|
5
|
-
const
|
|
6
|
-
for (let i = 0; i <
|
|
7
|
-
|
|
6
|
+
const rawHeaders = incoming.rawHeaders;
|
|
7
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
8
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
9
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
10
|
+
58) {
|
|
11
|
+
headerRecord.push([key, value]);
|
|
12
|
+
}
|
|
8
13
|
}
|
|
9
14
|
const init = {
|
|
10
15
|
method,
|
|
@@ -19,15 +24,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
19
24
|
var getRequestCache = Symbol("getRequestCache");
|
|
20
25
|
var requestCache = Symbol("requestCache");
|
|
21
26
|
var incomingKey = Symbol("incomingKey");
|
|
27
|
+
var urlKey = Symbol("urlKey");
|
|
22
28
|
var requestPrototype = {
|
|
23
29
|
get method() {
|
|
24
30
|
return this[incomingKey].method || "GET";
|
|
25
31
|
},
|
|
26
32
|
get url() {
|
|
27
|
-
return
|
|
33
|
+
return this[urlKey];
|
|
28
34
|
},
|
|
29
35
|
[getRequestCache]() {
|
|
30
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
36
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
37
|
+
this.method,
|
|
38
|
+
this[urlKey],
|
|
39
|
+
this[incomingKey]
|
|
40
|
+
);
|
|
31
41
|
}
|
|
32
42
|
};
|
|
33
43
|
[
|
|
@@ -61,6 +71,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
61
71
|
var newRequest = (incoming) => {
|
|
62
72
|
const req = Object.create(requestPrototype);
|
|
63
73
|
req[incomingKey] = incoming;
|
|
74
|
+
req[urlKey] = new URL(
|
|
75
|
+
`http://${incoming instanceof Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
76
|
+
).href;
|
|
64
77
|
return req;
|
|
65
78
|
};
|
|
66
79
|
|
package/dist/request.js
CHANGED
|
@@ -23,12 +23,17 @@ __export(request_exports, {
|
|
|
23
23
|
newRequest: () => newRequest
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(request_exports);
|
|
26
|
+
var import_node_http2 = require("http2");
|
|
26
27
|
var import_node_stream = require("stream");
|
|
27
28
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
28
29
|
const headerRecord = [];
|
|
29
|
-
const
|
|
30
|
-
for (let i = 0; i <
|
|
31
|
-
|
|
30
|
+
const rawHeaders = incoming.rawHeaders;
|
|
31
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
32
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
33
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
34
|
+
58) {
|
|
35
|
+
headerRecord.push([key, value]);
|
|
36
|
+
}
|
|
32
37
|
}
|
|
33
38
|
const init = {
|
|
34
39
|
method,
|
|
@@ -43,15 +48,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
43
48
|
var getRequestCache = Symbol("getRequestCache");
|
|
44
49
|
var requestCache = Symbol("requestCache");
|
|
45
50
|
var incomingKey = Symbol("incomingKey");
|
|
51
|
+
var urlKey = Symbol("urlKey");
|
|
46
52
|
var requestPrototype = {
|
|
47
53
|
get method() {
|
|
48
54
|
return this[incomingKey].method || "GET";
|
|
49
55
|
},
|
|
50
56
|
get url() {
|
|
51
|
-
return
|
|
57
|
+
return this[urlKey];
|
|
52
58
|
},
|
|
53
59
|
[getRequestCache]() {
|
|
54
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
60
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
61
|
+
this.method,
|
|
62
|
+
this[urlKey],
|
|
63
|
+
this[incomingKey]
|
|
64
|
+
);
|
|
55
65
|
}
|
|
56
66
|
};
|
|
57
67
|
[
|
|
@@ -85,6 +95,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
85
95
|
var newRequest = (incoming) => {
|
|
86
96
|
const req = Object.create(requestPrototype);
|
|
87
97
|
req[incomingKey] = incoming;
|
|
98
|
+
req[urlKey] = new URL(
|
|
99
|
+
`http://${incoming instanceof import_node_http2.Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
100
|
+
).href;
|
|
88
101
|
return req;
|
|
89
102
|
};
|
|
90
103
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/request.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// src/request.ts
|
|
2
|
+
import { Http2ServerRequest } from "http2";
|
|
2
3
|
import { Readable } from "stream";
|
|
3
4
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
4
5
|
const headerRecord = [];
|
|
5
|
-
const
|
|
6
|
-
for (let i = 0; i <
|
|
7
|
-
|
|
6
|
+
const rawHeaders = incoming.rawHeaders;
|
|
7
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
8
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
9
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
10
|
+
58) {
|
|
11
|
+
headerRecord.push([key, value]);
|
|
12
|
+
}
|
|
8
13
|
}
|
|
9
14
|
const init = {
|
|
10
15
|
method,
|
|
@@ -19,15 +24,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
19
24
|
var getRequestCache = Symbol("getRequestCache");
|
|
20
25
|
var requestCache = Symbol("requestCache");
|
|
21
26
|
var incomingKey = Symbol("incomingKey");
|
|
27
|
+
var urlKey = Symbol("urlKey");
|
|
22
28
|
var requestPrototype = {
|
|
23
29
|
get method() {
|
|
24
30
|
return this[incomingKey].method || "GET";
|
|
25
31
|
},
|
|
26
32
|
get url() {
|
|
27
|
-
return
|
|
33
|
+
return this[urlKey];
|
|
28
34
|
},
|
|
29
35
|
[getRequestCache]() {
|
|
30
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
36
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
37
|
+
this.method,
|
|
38
|
+
this[urlKey],
|
|
39
|
+
this[incomingKey]
|
|
40
|
+
);
|
|
31
41
|
}
|
|
32
42
|
};
|
|
33
43
|
[
|
|
@@ -61,6 +71,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
61
71
|
var newRequest = (incoming) => {
|
|
62
72
|
const req = Object.create(requestPrototype);
|
|
63
73
|
req[incomingKey] = incoming;
|
|
74
|
+
req[urlKey] = new URL(
|
|
75
|
+
`http://${incoming instanceof Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
76
|
+
).href;
|
|
64
77
|
return req;
|
|
65
78
|
};
|
|
66
79
|
export {
|
package/dist/server.js
CHANGED
|
@@ -37,12 +37,17 @@ module.exports = __toCommonJS(server_exports);
|
|
|
37
37
|
var import_node_http = require("http");
|
|
38
38
|
|
|
39
39
|
// src/request.ts
|
|
40
|
+
var import_node_http2 = require("http2");
|
|
40
41
|
var import_node_stream = require("stream");
|
|
41
42
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
42
43
|
const headerRecord = [];
|
|
43
|
-
const
|
|
44
|
-
for (let i = 0; i <
|
|
45
|
-
|
|
44
|
+
const rawHeaders = incoming.rawHeaders;
|
|
45
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
46
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
47
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
48
|
+
58) {
|
|
49
|
+
headerRecord.push([key, value]);
|
|
50
|
+
}
|
|
46
51
|
}
|
|
47
52
|
const init = {
|
|
48
53
|
method,
|
|
@@ -57,15 +62,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
57
62
|
var getRequestCache = Symbol("getRequestCache");
|
|
58
63
|
var requestCache = Symbol("requestCache");
|
|
59
64
|
var incomingKey = Symbol("incomingKey");
|
|
65
|
+
var urlKey = Symbol("urlKey");
|
|
60
66
|
var requestPrototype = {
|
|
61
67
|
get method() {
|
|
62
68
|
return this[incomingKey].method || "GET";
|
|
63
69
|
},
|
|
64
70
|
get url() {
|
|
65
|
-
return
|
|
71
|
+
return this[urlKey];
|
|
66
72
|
},
|
|
67
73
|
[getRequestCache]() {
|
|
68
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
74
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
75
|
+
this.method,
|
|
76
|
+
this[urlKey],
|
|
77
|
+
this[incomingKey]
|
|
78
|
+
);
|
|
69
79
|
}
|
|
70
80
|
};
|
|
71
81
|
[
|
|
@@ -99,6 +109,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
99
109
|
var newRequest = (incoming) => {
|
|
100
110
|
const req = Object.create(requestPrototype);
|
|
101
111
|
req[incomingKey] = incoming;
|
|
112
|
+
req[urlKey] = new URL(
|
|
113
|
+
`http://${incoming instanceof import_node_http2.Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
114
|
+
).href;
|
|
102
115
|
return req;
|
|
103
116
|
};
|
|
104
117
|
|
package/dist/server.mjs
CHANGED
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
import { createServer as createServerHTTP } from "http";
|
|
3
3
|
|
|
4
4
|
// src/request.ts
|
|
5
|
+
import { Http2ServerRequest } from "http2";
|
|
5
6
|
import { Readable } from "stream";
|
|
6
7
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
7
8
|
const headerRecord = [];
|
|
8
|
-
const
|
|
9
|
-
for (let i = 0; i <
|
|
10
|
-
|
|
9
|
+
const rawHeaders = incoming.rawHeaders;
|
|
10
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
11
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
12
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
13
|
+
58) {
|
|
14
|
+
headerRecord.push([key, value]);
|
|
15
|
+
}
|
|
11
16
|
}
|
|
12
17
|
const init = {
|
|
13
18
|
method,
|
|
@@ -22,15 +27,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
22
27
|
var getRequestCache = Symbol("getRequestCache");
|
|
23
28
|
var requestCache = Symbol("requestCache");
|
|
24
29
|
var incomingKey = Symbol("incomingKey");
|
|
30
|
+
var urlKey = Symbol("urlKey");
|
|
25
31
|
var requestPrototype = {
|
|
26
32
|
get method() {
|
|
27
33
|
return this[incomingKey].method || "GET";
|
|
28
34
|
},
|
|
29
35
|
get url() {
|
|
30
|
-
return
|
|
36
|
+
return this[urlKey];
|
|
31
37
|
},
|
|
32
38
|
[getRequestCache]() {
|
|
33
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
39
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
40
|
+
this.method,
|
|
41
|
+
this[urlKey],
|
|
42
|
+
this[incomingKey]
|
|
43
|
+
);
|
|
34
44
|
}
|
|
35
45
|
};
|
|
36
46
|
[
|
|
@@ -64,6 +74,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
64
74
|
var newRequest = (incoming) => {
|
|
65
75
|
const req = Object.create(requestPrototype);
|
|
66
76
|
req[incomingKey] = incoming;
|
|
77
|
+
req[urlKey] = new URL(
|
|
78
|
+
`http://${incoming instanceof Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
79
|
+
).href;
|
|
67
80
|
return req;
|
|
68
81
|
};
|
|
69
82
|
|
package/dist/vercel.js
CHANGED
|
@@ -35,12 +35,17 @@ __export(vercel_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(vercel_exports);
|
|
36
36
|
|
|
37
37
|
// src/request.ts
|
|
38
|
+
var import_node_http2 = require("http2");
|
|
38
39
|
var import_node_stream = require("stream");
|
|
39
40
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
40
41
|
const headerRecord = [];
|
|
41
|
-
const
|
|
42
|
-
for (let i = 0; i <
|
|
43
|
-
|
|
42
|
+
const rawHeaders = incoming.rawHeaders;
|
|
43
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
44
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
45
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
46
|
+
58) {
|
|
47
|
+
headerRecord.push([key, value]);
|
|
48
|
+
}
|
|
44
49
|
}
|
|
45
50
|
const init = {
|
|
46
51
|
method,
|
|
@@ -55,15 +60,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
55
60
|
var getRequestCache = Symbol("getRequestCache");
|
|
56
61
|
var requestCache = Symbol("requestCache");
|
|
57
62
|
var incomingKey = Symbol("incomingKey");
|
|
63
|
+
var urlKey = Symbol("urlKey");
|
|
58
64
|
var requestPrototype = {
|
|
59
65
|
get method() {
|
|
60
66
|
return this[incomingKey].method || "GET";
|
|
61
67
|
},
|
|
62
68
|
get url() {
|
|
63
|
-
return
|
|
69
|
+
return this[urlKey];
|
|
64
70
|
},
|
|
65
71
|
[getRequestCache]() {
|
|
66
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
72
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
73
|
+
this.method,
|
|
74
|
+
this[urlKey],
|
|
75
|
+
this[incomingKey]
|
|
76
|
+
);
|
|
67
77
|
}
|
|
68
78
|
};
|
|
69
79
|
[
|
|
@@ -97,6 +107,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
97
107
|
var newRequest = (incoming) => {
|
|
98
108
|
const req = Object.create(requestPrototype);
|
|
99
109
|
req[incomingKey] = incoming;
|
|
110
|
+
req[urlKey] = new URL(
|
|
111
|
+
`http://${incoming instanceof import_node_http2.Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
112
|
+
).href;
|
|
100
113
|
return req;
|
|
101
114
|
};
|
|
102
115
|
|
package/dist/vercel.mjs
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
// src/request.ts
|
|
2
|
+
import { Http2ServerRequest } from "http2";
|
|
2
3
|
import { Readable } from "stream";
|
|
3
4
|
var newRequestFromIncoming = (method, url, incoming) => {
|
|
4
5
|
const headerRecord = [];
|
|
5
|
-
const
|
|
6
|
-
for (let i = 0; i <
|
|
7
|
-
|
|
6
|
+
const rawHeaders = incoming.rawHeaders;
|
|
7
|
+
for (let i = 0; i < rawHeaders.length; i += 2) {
|
|
8
|
+
const { [i]: key, [i + 1]: value } = rawHeaders;
|
|
9
|
+
if (key.charCodeAt(0) !== /*:*/
|
|
10
|
+
58) {
|
|
11
|
+
headerRecord.push([key, value]);
|
|
12
|
+
}
|
|
8
13
|
}
|
|
9
14
|
const init = {
|
|
10
15
|
method,
|
|
@@ -19,15 +24,20 @@ var newRequestFromIncoming = (method, url, incoming) => {
|
|
|
19
24
|
var getRequestCache = Symbol("getRequestCache");
|
|
20
25
|
var requestCache = Symbol("requestCache");
|
|
21
26
|
var incomingKey = Symbol("incomingKey");
|
|
27
|
+
var urlKey = Symbol("urlKey");
|
|
22
28
|
var requestPrototype = {
|
|
23
29
|
get method() {
|
|
24
30
|
return this[incomingKey].method || "GET";
|
|
25
31
|
},
|
|
26
32
|
get url() {
|
|
27
|
-
return
|
|
33
|
+
return this[urlKey];
|
|
28
34
|
},
|
|
29
35
|
[getRequestCache]() {
|
|
30
|
-
return this[requestCache] ||= newRequestFromIncoming(
|
|
36
|
+
return this[requestCache] ||= newRequestFromIncoming(
|
|
37
|
+
this.method,
|
|
38
|
+
this[urlKey],
|
|
39
|
+
this[incomingKey]
|
|
40
|
+
);
|
|
31
41
|
}
|
|
32
42
|
};
|
|
33
43
|
[
|
|
@@ -61,6 +71,9 @@ Object.setPrototypeOf(requestPrototype, global.Request.prototype);
|
|
|
61
71
|
var newRequest = (incoming) => {
|
|
62
72
|
const req = Object.create(requestPrototype);
|
|
63
73
|
req[incomingKey] = incoming;
|
|
74
|
+
req[urlKey] = new URL(
|
|
75
|
+
`http://${incoming instanceof Http2ServerRequest ? incoming.authority : incoming.headers.host}${incoming.url}`
|
|
76
|
+
).href;
|
|
64
77
|
return req;
|
|
65
78
|
};
|
|
66
79
|
|