Socket
Socket
Sign inDemoInstall

@miniflare/http-server

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@miniflare/http-server - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

42

dist/src/index.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc