mitm-papandreou
Advanced tools
Comparing version 1.3.3-patch5 to 1.5.0-patch1
@@ -1,2 +0,6 @@ | ||
## Unreleased | ||
## 1.5.0 (Nov 29, 2018) | ||
- Adds compatibility with Node v11.1. | ||
- Adds compatibility with Node v11.2. | ||
## 1.4.0 (Sep 17, 2018) | ||
- Adds Node v8.12, Node v9 and Node v10 support. | ||
@@ -3,0 +7,0 @@ Thanks to [Andreas Lind](https://github.com/papandreou) for help in debugging! Also thanks to him for providing [mitm-papandreou](https://www.npmjs.com/package/mitm-papandreou) while Mitm.js-proper incorporated his fixes. |
@@ -5,2 +5,4 @@ var DuplexStream = require("stream").Duplex | ||
var NO_ERROR = 0 | ||
var STREAM_STATE | ||
var STREAM_BYTES_READ | ||
exports = module.exports = InternalSocket | ||
@@ -11,4 +13,10 @@ exports.pair = pair | ||
var NODE_10_AND_LATER = Semver.satisfies(process.version, ">= 10") | ||
if (!NODE_0_10) var Uv = process.binding("uv") | ||
var NODE_11_1_AND_LATER = Semver.satisfies(process.version, ">= 11.1") | ||
if (!NODE_0_10) var UV_EOF = process.binding("uv").UV_EOF | ||
if (NODE_11_1_AND_LATER) { | ||
STREAM_STATE = process.binding("stream_wrap").streamBaseState | ||
STREAM_BYTES_READ = process.binding("stream_wrap").kReadBytesOrError | ||
} | ||
/** | ||
@@ -55,3 +63,3 @@ * Sockets write to InternalSocket via write*String functions. The | ||
// getAsyncId was added in Node v8. | ||
// Node v8 added "getAsyncId". | ||
InternalSocket.prototype.getAsyncId = function() { return this.id } | ||
@@ -116,2 +124,9 @@ | ||
// While it seems to have existed since Node v0.10, Node v11.2 requires | ||
// "showdown". | ||
if (NODE_11_1_AND_LATER) InternalSocket.prototype.shutdown = function(req) { | ||
this.once("end", req.oncomplete.bind(req, NO_ERROR, req.handle)) | ||
this.end() | ||
} | ||
// Node v0.10 will use writeQueueSize to see if it should set write request's | ||
@@ -128,12 +143,20 @@ // "cb" property or write more immediately. | ||
function readData(data) { | ||
if (NODE_0_10) this.onread(data, 0, data.length) | ||
else this.onread(data.length, data) | ||
if (NODE_0_10) return void this.onread(data, 0, data.length) | ||
if (!NODE_11_1_AND_LATER) return void this.onread(data.length, data) | ||
// A system written not in 1960 that passes arguments to functions through | ||
// _global_ mutable data structures… | ||
STREAM_STATE[STREAM_BYTES_READ] = data.length | ||
this.onread(data) | ||
} | ||
function readEof() { | ||
if (!this.onread) return | ||
if (NODE_0_10) { process._errno = "EOF"; this.onread(null, 0, 0) } | ||
else this.onread(Uv.UV_EOF) | ||
if (this.onread == null) return | ||
if (NODE_0_10) { process._errno = "EOF"; this.onread(null, 0, 0); return } | ||
if (!NODE_11_1_AND_LATER) return void this.onread(UV_EOF) | ||
STREAM_STATE[STREAM_BYTES_READ] = UV_EOF | ||
this.onread() | ||
} | ||
function noop() {} |
{ | ||
"name": "mitm-papandreou", | ||
"version": "1.3.3-patch5", | ||
"version": "1.5.0-patch1", | ||
"description": "Intercept and mock outgoing network TCP connections and HTTP requests for testing. Intercepts and gives you a Net.Socket, Http.IncomingMessage and Http.ServerResponse to test and respond with. Useful when testing code that hits remote servers.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -51,3 +51,3 @@ Mitm.js | ||
socket.setEncoding("utf8") | ||
socket.read() // => "Hello back!" | ||
socket.on("data", console.log) // => "Hello back!" | ||
``` | ||
@@ -153,3 +153,3 @@ | ||
socket.setEncoding("utf8") | ||
socket.read() // => "Hello back!" | ||
socket.on("data", console.log) // => "Hello back!" | ||
``` | ||
@@ -156,0 +156,0 @@ |
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
55729
922