Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unexpected-mitm

Package Overview
Dependencies
Maintainers
5
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unexpected-mitm - npm Package Compare versions

Comparing version 9.2.0 to 9.2.1

28

lib/unexpectedMitm.js

@@ -270,12 +270,12 @@ /* global setImmediate, process, after, console */

function hasTrailerChunk(chunk) {
return isTrailerChunk(chunk.slice(-5));
}
function isTrailerChunk(chunk) {
return chunk === '0\r\n\r\n';
return chunk.slice(-4).toString() === '\r\n\r\n';
}
function attachConnectionHook(connection, callback) {
var bodyByteCount = 0;
var contentLengthByteCount = 0;
var hasContentLength = false;
var rawChunks = [];
var sawHeaders = false;
var _write = connection._write;

@@ -288,7 +288,19 @@

connection._write = function (chunk, encoding, cb) {
var isBuffer = Buffer.isBuffer(chunk);
chunk = Buffer.isBuffer(chunk) ? chunk : new Buffer(chunk);
rawChunks.push(isBuffer ? chunk : new Buffer(chunk));
rawChunks.push(chunk);
if (isTrailerChunk(chunk) || hasTrailerChunk(chunk)) {
if (!sawHeaders) {
var match = chunk.toString().match(/Content-Length: (\d+)/);
if (match) {
contentLengthByteCount = +match[1];
hasContentLength = true;
}
sawHeaders = true;
} else {
bodyByteCount += chunk.length;
}
if ((isTrailerChunk(chunk) && !hasContentLength) ||
(hasContentLength && bodyByteCount === contentLengthByteCount)) {
/*

@@ -295,0 +307,0 @@ * explicitly execute the callback returning raw data here

{
"name": "unexpected-mitm",
"version": "9.2.0",
"version": "9.2.1",
"description": "Unexpected plugin for the mitm library",

@@ -5,0 +5,0 @@ "author": "Andreas Lind <andreas@one.com>",

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