srvx 0.8.15 → 0.9.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/README.md +1 -1
- package/dist/_chunks/{_inherit-DLZfB57K.mjs → _inherit-BoJ2sCH1.mjs} +2 -1
- package/dist/_chunks/{_url-Q_-LB8LX.mjs → _url-DjsXG6si.mjs} +4 -1
- package/dist/_chunks/call-Ca6cbyoe.mjs +157 -0
- package/dist/_chunks/call-Ccm3CgTV.mjs +4 -0
- package/dist/_chunks/{types-hx5EhU1U.d.mts → types-4jUOEbJe.d.mts} +14 -10
- package/dist/adapters/bun.d.mts +2 -2
- package/dist/adapters/bun.mjs +4 -4
- package/dist/adapters/cloudflare.d.mts +1 -1
- package/dist/adapters/cloudflare.mjs +2 -2
- package/dist/adapters/deno.d.mts +1 -1
- package/dist/adapters/deno.mjs +4 -4
- package/dist/adapters/generic.d.mts +1 -1
- package/dist/adapters/generic.mjs +3 -3
- package/dist/adapters/node.d.mts +37 -21
- package/dist/adapters/node.mjs +431 -66
- package/dist/adapters/service-worker.d.mts +1 -1
- package/dist/adapters/service-worker.mjs +2 -2
- package/dist/cli.mjs +9 -13
- package/dist/log.d.mts +1 -1
- package/dist/static.d.mts +1 -1
- package/dist/static.mjs +4 -1
- package/dist/types.d.mts +1 -1
- package/package.json +16 -13
- package/dist/_chunks/call-DTWzxxQv.mjs +0 -44
- package/dist/_chunks/response-CsTwgR_V.mjs +0 -275
- /package/dist/_chunks/{_middleware-BvRR7B4M.mjs → _middleware-Z-W2xNSK.mjs} +0 -0
- /package/dist/_chunks/{_plugins-DmMfurBQ.mjs → _plugins-DOhVIkXu.mjs} +0 -0
- /package/dist/_chunks/{_utils-DRF_4b_y.mjs → _utils-dqVgpDNy.mjs} +0 -0
package/dist/static.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import "./_chunks/_inherit-BoJ2sCH1.mjs";
|
|
2
|
+
import { FastURL$1 as FastURL } from "./_chunks/_url-DjsXG6si.mjs";
|
|
1
3
|
import { extname, join, resolve } from "node:path";
|
|
2
4
|
import { createReadStream } from "node:fs";
|
|
3
5
|
import { readFile, stat } from "node:fs/promises";
|
|
@@ -33,7 +35,8 @@ const serveStatic = (options) => {
|
|
|
33
35
|
const methods = new Set((options.methods || ["GET", "HEAD"]).map((m) => m.toUpperCase()));
|
|
34
36
|
return async (req, next) => {
|
|
35
37
|
if (!methods.has(req.method)) return next();
|
|
36
|
-
const
|
|
38
|
+
const url = req._url ??= new FastURL(req.url);
|
|
39
|
+
const path = url.pathname.slice(1).replace(/\/$/, "");
|
|
37
40
|
let paths;
|
|
38
41
|
if (path === "") paths = ["index.html"];
|
|
39
42
|
else if (extname(path) === "") paths = [`${path}.html`, `${path}/index.html`];
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTPMiddleware, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, serve } from "./_chunks/types-
|
|
1
|
+
import { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTPMiddleware, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, serve } from "./_chunks/types-4jUOEbJe.mjs";
|
|
2
2
|
export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHTTPMiddleware, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRequestContext, ServerRuntimeContext, serve };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srvx",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Universal Server API based on web platform standards. Works seamlessly with Deno, Bun and Node.js.",
|
|
5
5
|
"homepage": "https://srvx.h3.dev",
|
|
6
6
|
"repository": "h3js/srvx",
|
|
@@ -49,44 +49,47 @@
|
|
|
49
49
|
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
|
|
50
50
|
"srvx": "./bin/srvx.mjs",
|
|
51
51
|
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
|
|
52
|
-
"test:
|
|
52
|
+
"test:node-compat:deno": "deno run vitest test/node.test",
|
|
53
|
+
"test:node-compat:bun": "bun test test/node.test.ts",
|
|
54
|
+
"test:types": "tsc --noEmit --skipLibCheck",
|
|
55
|
+
"vitest": "vitest"
|
|
53
56
|
},
|
|
54
57
|
"resolutions": {
|
|
55
58
|
"srvx": "link:."
|
|
56
59
|
},
|
|
57
|
-
"dependencies": {
|
|
58
|
-
"cookie-es": "^2.0.0"
|
|
59
|
-
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@cloudflare/workers-types": "^4.
|
|
61
|
+
"@cloudflare/workers-types": "^4.20251014.0",
|
|
62
62
|
"@hono/node-server": "^1.19.5",
|
|
63
63
|
"@mitata/counters": "^0.0.8",
|
|
64
64
|
"@mjackson/node-fetch-server": "^0.7.0",
|
|
65
|
-
"@types/bun": "^1.
|
|
65
|
+
"@types/bun": "^1.3.0",
|
|
66
66
|
"@types/deno": "^2.5.0",
|
|
67
|
-
"@types/
|
|
67
|
+
"@types/express": "^5.0.3",
|
|
68
|
+
"@types/node": "^24.9.0",
|
|
68
69
|
"@types/node-forge": "^1.3.14",
|
|
69
|
-
"@types/serviceworker": "^0.0.
|
|
70
|
+
"@types/serviceworker": "^0.0.158",
|
|
70
71
|
"@vitest/coverage-v8": "^3.2.4",
|
|
71
|
-
"@whatwg-node/server": "^0.10.
|
|
72
|
+
"@whatwg-node/server": "^0.10.13",
|
|
72
73
|
"automd": "^0.4.2",
|
|
73
74
|
"changelogen": "^0.6.2",
|
|
74
|
-
"eslint": "^9.
|
|
75
|
+
"eslint": "^9.38.0",
|
|
75
76
|
"eslint-config-unjs": "^0.5.0",
|
|
76
77
|
"execa": "^9.6.0",
|
|
78
|
+
"express": "^5.1.0",
|
|
79
|
+
"fastify": "^5.6.1",
|
|
77
80
|
"get-port-please": "^3.2.0",
|
|
78
81
|
"mdbox": "^0.1.1",
|
|
79
82
|
"mitata": "^1.0.34",
|
|
80
83
|
"node-forge": "^1.3.1",
|
|
81
84
|
"obuild": "^0.2.1",
|
|
82
85
|
"prettier": "^3.6.2",
|
|
83
|
-
"srvx-release": "npm:srvx@0.8.
|
|
86
|
+
"srvx-release": "npm:srvx@0.8.16",
|
|
84
87
|
"tslib": "^2.8.1",
|
|
85
88
|
"typescript": "^5.9.3",
|
|
86
89
|
"undici": "^7.16.0",
|
|
87
90
|
"vitest": "^3.2.4"
|
|
88
91
|
},
|
|
89
|
-
"packageManager": "pnpm@10.18.
|
|
92
|
+
"packageManager": "pnpm@10.18.3",
|
|
90
93
|
"engines": {
|
|
91
94
|
"node": ">=20.16.0"
|
|
92
95
|
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import "./_inherit-DLZfB57K.mjs";
|
|
2
|
-
import { NodeResponse, NodeResponseHeaders } from "./response-CsTwgR_V.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/adapters/_node/call.ts
|
|
5
|
-
function callNodeHandler(handler, req) {
|
|
6
|
-
const isMiddleware = handler.length > 2;
|
|
7
|
-
const nodeCtx = req.runtime?.node;
|
|
8
|
-
if (!nodeCtx || !nodeCtx.req || !nodeCtx.res) throw new Error("Node.js runtime context is not available.");
|
|
9
|
-
const { req: nodeReq, res: nodeRes } = nodeCtx;
|
|
10
|
-
let _headers;
|
|
11
|
-
const webRes = new NodeResponse(void 0, {
|
|
12
|
-
get status() {
|
|
13
|
-
return nodeRes.statusCode;
|
|
14
|
-
},
|
|
15
|
-
get statusText() {
|
|
16
|
-
return nodeRes.statusMessage;
|
|
17
|
-
},
|
|
18
|
-
get headers() {
|
|
19
|
-
if (!_headers) _headers = new NodeResponseHeaders(nodeCtx);
|
|
20
|
-
return _headers;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return new Promise((resolve, reject) => {
|
|
24
|
-
nodeRes.once("close", () => resolve(webRes));
|
|
25
|
-
nodeRes.once("finish", () => resolve(webRes));
|
|
26
|
-
nodeRes.once("error", (error) => reject(error));
|
|
27
|
-
let streamPromise;
|
|
28
|
-
nodeRes.once("pipe", (stream) => {
|
|
29
|
-
streamPromise = new Promise((resolve$1) => {
|
|
30
|
-
stream.once("end", () => resolve$1(webRes));
|
|
31
|
-
stream.once("error", (error) => reject(error));
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
try {
|
|
35
|
-
if (isMiddleware) Promise.resolve(handler(nodeReq, nodeRes, (error) => error ? reject(error) : streamPromise || resolve(webRes))).catch((error) => reject(error));
|
|
36
|
-
else Promise.resolve(handler(nodeReq, nodeRes)).then(() => streamPromise || webRes);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
reject(error);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
export { callNodeHandler };
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import { lazyInherit } from "./_inherit-DLZfB57K.mjs";
|
|
2
|
-
import { splitSetCookieString } from "cookie-es";
|
|
3
|
-
|
|
4
|
-
//#region src/adapters/_node/_common.ts
|
|
5
|
-
const kNodeInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
6
|
-
|
|
7
|
-
//#endregion
|
|
8
|
-
//#region src/adapters/_node/headers.ts
|
|
9
|
-
const NodeRequestHeaders = /* @__PURE__ */ (() => {
|
|
10
|
-
const _Headers = class Headers$1 {
|
|
11
|
-
_node;
|
|
12
|
-
constructor(nodeCtx) {
|
|
13
|
-
this._node = nodeCtx;
|
|
14
|
-
}
|
|
15
|
-
append(name, value) {
|
|
16
|
-
name = validateHeader(name);
|
|
17
|
-
const _headers = this._node.req.headers;
|
|
18
|
-
const _current = _headers[name];
|
|
19
|
-
if (_current) if (Array.isArray(_current)) _current.push(value);
|
|
20
|
-
else _headers[name] = [_current, value];
|
|
21
|
-
else _headers[name] = value;
|
|
22
|
-
}
|
|
23
|
-
delete(name) {
|
|
24
|
-
name = validateHeader(name);
|
|
25
|
-
this._node.req.headers[name] = void 0;
|
|
26
|
-
}
|
|
27
|
-
get(name) {
|
|
28
|
-
name = validateHeader(name);
|
|
29
|
-
const rawValue = this._node.req.headers[name];
|
|
30
|
-
if (rawValue === void 0) return null;
|
|
31
|
-
return _normalizeValue(this._node.req.headers[name]);
|
|
32
|
-
}
|
|
33
|
-
getSetCookie() {
|
|
34
|
-
const setCookie = this._node.req.headers["set-cookie"];
|
|
35
|
-
if (!setCookie || setCookie.length === 0) return [];
|
|
36
|
-
return splitSetCookieString(setCookie);
|
|
37
|
-
}
|
|
38
|
-
has(name) {
|
|
39
|
-
name = validateHeader(name);
|
|
40
|
-
return !!this._node.req.headers[name];
|
|
41
|
-
}
|
|
42
|
-
set(name, value) {
|
|
43
|
-
name = validateHeader(name);
|
|
44
|
-
this._node.req.headers[name] = value;
|
|
45
|
-
}
|
|
46
|
-
get count() {
|
|
47
|
-
throw new Error("Method not implemented.");
|
|
48
|
-
}
|
|
49
|
-
getAll(_name) {
|
|
50
|
-
throw new Error("Method not implemented.");
|
|
51
|
-
}
|
|
52
|
-
toJSON() {
|
|
53
|
-
const _headers = this._node.req.headers;
|
|
54
|
-
const result = {};
|
|
55
|
-
for (const key in _headers) if (_headers[key]) result[key] = _normalizeValue(_headers[key]);
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
forEach(cb, thisArg) {
|
|
59
|
-
const _headers = this._node.req.headers;
|
|
60
|
-
for (const key in _headers) if (_headers[key]) cb.call(thisArg, _normalizeValue(_headers[key]), key, this);
|
|
61
|
-
}
|
|
62
|
-
*entries() {
|
|
63
|
-
const headers = this._node.req.headers;
|
|
64
|
-
const isHttp2 = this._node.req.httpVersion === "2.0";
|
|
65
|
-
for (const key in headers) if (!isHttp2 || key[0] !== ":") yield [key, _normalizeValue(headers[key])];
|
|
66
|
-
}
|
|
67
|
-
*keys() {
|
|
68
|
-
const keys = Object.keys(this._node.req.headers);
|
|
69
|
-
for (const key of keys) yield key;
|
|
70
|
-
}
|
|
71
|
-
*values() {
|
|
72
|
-
const values = Object.values(this._node.req.headers);
|
|
73
|
-
for (const value of values) yield _normalizeValue(value);
|
|
74
|
-
}
|
|
75
|
-
[Symbol.iterator]() {
|
|
76
|
-
return this.entries()[Symbol.iterator]();
|
|
77
|
-
}
|
|
78
|
-
get [Symbol.toStringTag]() {
|
|
79
|
-
return "Headers";
|
|
80
|
-
}
|
|
81
|
-
[kNodeInspect]() {
|
|
82
|
-
return Object.fromEntries(this.entries());
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
Object.setPrototypeOf(_Headers.prototype, globalThis.Headers.prototype);
|
|
86
|
-
return _Headers;
|
|
87
|
-
})();
|
|
88
|
-
const NodeResponseHeaders = /* @__PURE__ */ (() => {
|
|
89
|
-
const _Headers = class Headers$1 {
|
|
90
|
-
_node;
|
|
91
|
-
constructor(nodeCtx) {
|
|
92
|
-
this._node = nodeCtx;
|
|
93
|
-
}
|
|
94
|
-
append(name, value) {
|
|
95
|
-
this._node.res.appendHeader(name, value);
|
|
96
|
-
}
|
|
97
|
-
delete(name) {
|
|
98
|
-
this._node.res.removeHeader(name);
|
|
99
|
-
}
|
|
100
|
-
get(name) {
|
|
101
|
-
const rawValue = this._node.res.getHeader(name);
|
|
102
|
-
if (rawValue === void 0) return null;
|
|
103
|
-
return _normalizeValue(rawValue);
|
|
104
|
-
}
|
|
105
|
-
getSetCookie() {
|
|
106
|
-
const setCookie = _normalizeValue(this._node.res.getHeader("set-cookie"));
|
|
107
|
-
if (!setCookie) return [];
|
|
108
|
-
return splitSetCookieString(setCookie);
|
|
109
|
-
}
|
|
110
|
-
has(name) {
|
|
111
|
-
return this._node.res.hasHeader(name);
|
|
112
|
-
}
|
|
113
|
-
set(name, value) {
|
|
114
|
-
this._node.res.setHeader(name, value);
|
|
115
|
-
}
|
|
116
|
-
get count() {
|
|
117
|
-
throw new Error("Method not implemented.");
|
|
118
|
-
}
|
|
119
|
-
getAll(_name) {
|
|
120
|
-
throw new Error("Method not implemented.");
|
|
121
|
-
}
|
|
122
|
-
toJSON() {
|
|
123
|
-
const _headers = this._node.res.getHeaders();
|
|
124
|
-
const result = {};
|
|
125
|
-
for (const key in _headers) if (_headers[key]) result[key] = _normalizeValue(_headers[key]);
|
|
126
|
-
return result;
|
|
127
|
-
}
|
|
128
|
-
forEach(cb, thisArg) {
|
|
129
|
-
const _headers = this._node.res.getHeaders();
|
|
130
|
-
for (const key in _headers) if (_headers[key]) cb.call(thisArg, _normalizeValue(_headers[key]), key, this);
|
|
131
|
-
}
|
|
132
|
-
*entries() {
|
|
133
|
-
const _headers = this._node.res.getHeaders();
|
|
134
|
-
for (const key in _headers) yield [key, _normalizeValue(_headers[key])];
|
|
135
|
-
}
|
|
136
|
-
*keys() {
|
|
137
|
-
const keys = this._node.res.getHeaderNames();
|
|
138
|
-
for (const key of keys) yield key;
|
|
139
|
-
}
|
|
140
|
-
*values() {
|
|
141
|
-
const values = Object.values(this._node.res.getHeaders());
|
|
142
|
-
for (const value of values) yield _normalizeValue(value);
|
|
143
|
-
}
|
|
144
|
-
[Symbol.iterator]() {
|
|
145
|
-
return this.entries()[Symbol.iterator]();
|
|
146
|
-
}
|
|
147
|
-
get [Symbol.toStringTag]() {
|
|
148
|
-
return "Headers";
|
|
149
|
-
}
|
|
150
|
-
[kNodeInspect]() {
|
|
151
|
-
return Object.fromEntries(this.entries());
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
Object.setPrototypeOf(_Headers.prototype, globalThis.Headers.prototype);
|
|
155
|
-
return _Headers;
|
|
156
|
-
})();
|
|
157
|
-
function _normalizeValue(value) {
|
|
158
|
-
if (Array.isArray(value)) return value.join(", ");
|
|
159
|
-
return typeof value === "string" ? value : String(value ?? "");
|
|
160
|
-
}
|
|
161
|
-
function validateHeader(name) {
|
|
162
|
-
if (name[0] === ":") throw new TypeError(`${JSON.stringify(name)} is an invalid header name.`);
|
|
163
|
-
return name.toLowerCase();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
//#endregion
|
|
167
|
-
//#region src/adapters/_node/response.ts
|
|
168
|
-
/**
|
|
169
|
-
* Fast Response for Node.js runtime
|
|
170
|
-
*
|
|
171
|
-
* It is faster because in most cases it doesn't create a full Response instance.
|
|
172
|
-
*/
|
|
173
|
-
const NodeResponse = /* @__PURE__ */ (() => {
|
|
174
|
-
const NativeResponse = globalThis.Response;
|
|
175
|
-
const STATUS_CODES = globalThis.process?.getBuiltinModule?.("node:http")?.STATUS_CODES || {};
|
|
176
|
-
class NodeResponse$1 {
|
|
177
|
-
#body;
|
|
178
|
-
#init;
|
|
179
|
-
#headers;
|
|
180
|
-
#response;
|
|
181
|
-
constructor(body, init) {
|
|
182
|
-
this.#body = body;
|
|
183
|
-
this.#init = init;
|
|
184
|
-
}
|
|
185
|
-
get status() {
|
|
186
|
-
return this.#response?.status || this.#init?.status || 200;
|
|
187
|
-
}
|
|
188
|
-
get statusText() {
|
|
189
|
-
return this.#response?.statusText || this.#init?.statusText || STATUS_CODES[this.status] || "";
|
|
190
|
-
}
|
|
191
|
-
get headers() {
|
|
192
|
-
if (this.#response) return this.#response.headers;
|
|
193
|
-
if (this.#headers) return this.#headers;
|
|
194
|
-
const initHeaders = this.#init?.headers;
|
|
195
|
-
return this.#headers = initHeaders instanceof Headers ? initHeaders : new Headers(initHeaders);
|
|
196
|
-
}
|
|
197
|
-
get ok() {
|
|
198
|
-
if (this.#response) return this.#response.ok;
|
|
199
|
-
const status = this.status;
|
|
200
|
-
return status >= 200 && status < 300;
|
|
201
|
-
}
|
|
202
|
-
get _response() {
|
|
203
|
-
if (this.#response) return this.#response;
|
|
204
|
-
this.#response = new NativeResponse(this.#body, this.#headers ? {
|
|
205
|
-
...this.#init,
|
|
206
|
-
headers: this.#headers
|
|
207
|
-
} : this.#init);
|
|
208
|
-
this.#init = void 0;
|
|
209
|
-
this.#headers = void 0;
|
|
210
|
-
this.#body = void 0;
|
|
211
|
-
return this.#response;
|
|
212
|
-
}
|
|
213
|
-
nodeResponse() {
|
|
214
|
-
const status = this.status;
|
|
215
|
-
const statusText = this.statusText;
|
|
216
|
-
let body;
|
|
217
|
-
let contentType;
|
|
218
|
-
let contentLength;
|
|
219
|
-
if (this.#response) body = this.#response.body;
|
|
220
|
-
else if (this.#body) if (this.#body instanceof ReadableStream) body = this.#body;
|
|
221
|
-
else if (typeof this.#body === "string") {
|
|
222
|
-
body = this.#body;
|
|
223
|
-
contentType = "text/plain; charset=UTF-8";
|
|
224
|
-
contentLength = Buffer.byteLength(this.#body);
|
|
225
|
-
} else if (this.#body instanceof ArrayBuffer) {
|
|
226
|
-
body = Buffer.from(this.#body);
|
|
227
|
-
contentLength = this.#body.byteLength;
|
|
228
|
-
} else if (this.#body instanceof Uint8Array) {
|
|
229
|
-
body = this.#body;
|
|
230
|
-
contentLength = this.#body.byteLength;
|
|
231
|
-
} else if (this.#body instanceof DataView) {
|
|
232
|
-
body = Buffer.from(this.#body.buffer);
|
|
233
|
-
contentLength = this.#body.byteLength;
|
|
234
|
-
} else if (this.#body instanceof Blob) {
|
|
235
|
-
body = this.#body.stream();
|
|
236
|
-
contentType = this.#body.type;
|
|
237
|
-
contentLength = this.#body.size;
|
|
238
|
-
} else if (typeof this.#body.pipe === "function") body = this.#body;
|
|
239
|
-
else body = this._response.body;
|
|
240
|
-
const rawNodeHeaders = [];
|
|
241
|
-
const initHeaders = this.#init?.headers;
|
|
242
|
-
const headerEntries = this.#response?.headers || this.#headers || (initHeaders ? Array.isArray(initHeaders) ? initHeaders : initHeaders?.entries ? initHeaders.entries() : Object.entries(initHeaders).map(([k, v]) => [k.toLowerCase(), v]) : void 0);
|
|
243
|
-
let hasContentTypeHeader;
|
|
244
|
-
let hasContentLength;
|
|
245
|
-
if (headerEntries) for (const [key, value] of headerEntries) {
|
|
246
|
-
if (key === "set-cookie") {
|
|
247
|
-
for (const setCookie of splitSetCookieString(value)) rawNodeHeaders.push(["set-cookie", setCookie]);
|
|
248
|
-
continue;
|
|
249
|
-
}
|
|
250
|
-
rawNodeHeaders.push([key, value]);
|
|
251
|
-
if (key === "content-type") hasContentTypeHeader = true;
|
|
252
|
-
else if (key === "content-length") hasContentLength = true;
|
|
253
|
-
}
|
|
254
|
-
if (contentType && !hasContentTypeHeader) rawNodeHeaders.push(["content-type", contentType]);
|
|
255
|
-
if (contentLength && !hasContentLength) rawNodeHeaders.push(["content-length", String(contentLength)]);
|
|
256
|
-
this.#init = void 0;
|
|
257
|
-
this.#headers = void 0;
|
|
258
|
-
this.#response = void 0;
|
|
259
|
-
this.#body = void 0;
|
|
260
|
-
return {
|
|
261
|
-
status,
|
|
262
|
-
statusText,
|
|
263
|
-
headers: rawNodeHeaders,
|
|
264
|
-
body
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
lazyInherit(NodeResponse$1.prototype, NativeResponse.prototype, "_response");
|
|
269
|
-
Object.setPrototypeOf(NodeResponse$1, NativeResponse);
|
|
270
|
-
Object.setPrototypeOf(NodeResponse$1.prototype, NativeResponse.prototype);
|
|
271
|
-
return NodeResponse$1;
|
|
272
|
-
})();
|
|
273
|
-
|
|
274
|
-
//#endregion
|
|
275
|
-
export { NodeRequestHeaders, NodeResponse, NodeResponseHeaders };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|