@miniflare/http-server
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -53,3 +53,2 @@ var __create = Object.create; | ||
var import_web_sockets = __toModule(require("@miniflare/web-sockets")); | ||
var import_undici2 = __toModule(require("undici")); | ||
@@ -433,14 +432,3 @@ // packages/http-server/src/helpers.ts | ||
req.headers["host"] = url.host; | ||
const headers = new import_undici2.Headers(); | ||
for (const [name, values] of Object.entries(req.headers)) { | ||
if (name === "transfer-encoding" || name === "connection" || name === "keep-alive" || name === "expect") { | ||
continue; | ||
} | ||
if (Array.isArray(values)) { | ||
for (const value of values) | ||
headers.append(name, value); | ||
} else if (values !== void 0) { | ||
headers.append(name, values); | ||
} | ||
} | ||
const headers = (0, import_core._headersFromIncomingRequest)(req); | ||
const request = new import_core.Request(url, { | ||
@@ -490,2 +478,6 @@ method: req.method, | ||
} | ||
const contentLengthHeader = response.headers.get("Content-Length"); | ||
const contentLength = (0, import_core._getBodyLength)(response) ?? (contentLengthHeader === null ? null : parseInt(contentLengthHeader)); | ||
if (contentLength !== null) | ||
headers["content-length"] = contentLength; | ||
const encoders = []; | ||
@@ -511,7 +503,5 @@ if (headers["content-encoding"] && response.encodeBody === "auto") { | ||
const liveReloadEnabled = HTTPPlugin2.liveReload && response.encodeBody === "auto" && response.headers.get("content-type")?.toLowerCase().includes("text/html"); | ||
const contentLength = response.headers.get("content-length"); | ||
if (liveReloadEnabled && contentLength !== null) { | ||
const length = parseInt(contentLength); | ||
if (!isNaN(length)) { | ||
headers["content-length"] = length + liveReloadScriptLength; | ||
if (!isNaN(contentLength)) { | ||
headers["content-length"] = contentLength + liveReloadScriptLength; | ||
} | ||
@@ -573,2 +563,7 @@ } | ||
} | ||
var restrictedWebSocketUpgradeHeaders = [ | ||
"upgrade", | ||
"connection", | ||
"sec-websocket-accept" | ||
]; | ||
async function createServer(mf, options) { | ||
@@ -588,2 +583,14 @@ const plugins = await mf.getPlugins(); | ||
const liveReloadServer = new WebSocketServer({ noServer: true }); | ||
const extraHeaders = new WeakMap(); | ||
webSocketServer.on("headers", (headers, req) => { | ||
const extra = extraHeaders.get(req); | ||
extraHeaders.delete(req); | ||
if (extra) { | ||
for (const [key, value] of extra) { | ||
if (!restrictedWebSocketUpgradeHeaders.includes(key)) { | ||
headers.push(`${key}: ${value}`); | ||
} | ||
} | ||
} | ||
}); | ||
server.on("upgrade", async (request, socket, head) => { | ||
@@ -604,2 +611,3 @@ const { pathname } = new import_url.URL(request.url ?? "", "http://localhost"); | ||
} | ||
extraHeaders.set(request, response.headers); | ||
webSocketServer.handleUpgrade(request, socket, head, (ws) => { | ||
@@ -606,0 +614,0 @@ void (0, import_web_sockets.coupleWebSocket)(ws, webSocket); |
{ | ||
"name": "@miniflare/http-server", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "HTTP server module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers", | ||
@@ -38,7 +38,7 @@ "keywords": [ | ||
"dependencies": { | ||
"@miniflare/core": "2.0.0", | ||
"@miniflare/shared": "2.0.0", | ||
"@miniflare/web-sockets": "2.0.0", | ||
"@miniflare/core": "2.1.0", | ||
"@miniflare/shared": "2.1.0", | ||
"@miniflare/web-sockets": "2.1.0", | ||
"kleur": "^4.1.4", | ||
"selfsigned": "^1.10.11", | ||
"selfsigned": "^2.0.0", | ||
"undici": "4.12.1", | ||
@@ -49,5 +49,5 @@ "ws": "^8.2.2", | ||
"devDependencies": { | ||
"@miniflare/shared-test": "2.0.0", | ||
"@miniflare/shared-test": "2.1.0", | ||
"@types/node-forge": "^0.10.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42153
745
+ Added@miniflare/core@2.1.0(transitive)
+ Added@miniflare/shared@2.1.0(transitive)
+ Added@miniflare/watcher@2.1.0(transitive)
+ Added@miniflare/web-sockets@2.1.0(transitive)
+ Added@types/node@22.5.5(transitive)
+ Added@types/node-forge@1.3.11(transitive)
+ Addednode-forge@1.3.1(transitive)
+ Addedselfsigned@2.4.1(transitive)
+ Addedundici-types@6.19.8(transitive)
- Removed@miniflare/core@2.0.0(transitive)
- Removed@miniflare/shared@2.0.0(transitive)
- Removed@miniflare/web-sockets@2.0.0(transitive)
- Removednode-forge@0.10.0(transitive)
- Removedselfsigned@1.10.14(transitive)
Updated@miniflare/core@2.1.0
Updated@miniflare/shared@2.1.0
Updated@miniflare/web-sockets@2.1.0
Updatedselfsigned@^2.0.0