unexpected-mitm
Advanced tools
Comparing version 9.2.0 to 9.2.1
@@ -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>", |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
57233
1039
1