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