Comparing version 1.2.1 to 1.3.0
@@ -0,1 +1,5 @@ | ||
## 1.3.0 (Aug 17, 2016) | ||
- Adds compatibility with Node v6.4. | ||
Thanks to [Andreas Lind](https://github.com/papandreou)! | ||
## 1.2.1 (Mar 30, 2016) | ||
@@ -2,0 +6,0 @@ - Fixes writing to sockets returned by Mitm by postponing writing until the next |
@@ -78,2 +78,6 @@ var DuplexStream = require("stream").Duplex | ||
InternalSocket.prototype.writeLatin1String = function(req, data) { | ||
this.write(data, "latin1") | ||
} | ||
InternalSocket.prototype.writeBuffer = function(req, data) { | ||
@@ -80,0 +84,0 @@ this.write(NODE_0_10 ? req : data) |
{ | ||
"name": "mitm", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"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.", | ||
@@ -46,3 +46,4 @@ "keywords": [ | ||
"must": ">= 0.13 < 0.14", | ||
"sinon": ">= 1.9 < 2" | ||
"sinon": ">= 1.9 < 2", | ||
"semver": ">= 5 < 6" | ||
}, | ||
@@ -49,0 +50,0 @@ |
@@ -198,3 +198,3 @@ Mitm.js | ||
mitm.on("connect", function(socket, opts) { | ||
if (opts.host == "sql.example.org" && opts.port = 5432) socket.bypass() | ||
if (opts.host == "sql.example.org" && opts.port == 5432) socket.bypass() | ||
}) | ||
@@ -201,0 +201,0 @@ ``` |
@@ -7,2 +7,3 @@ var _ = require("underscore") | ||
var Https = require("https") | ||
var Semver = require("semver") | ||
var IncomingMessage = Http.IncomingMessage | ||
@@ -13,3 +14,3 @@ var ServerResponse = Http.ServerResponse | ||
var Mitm = require("..") | ||
var NODE_0_10 = !!process.version.match(/^v0\.10\./) | ||
var NODE_0_10 = Semver.satisfies(process.version, ">= 0.10 < 0.11") | ||
@@ -238,3 +239,2 @@ describe("Mitm", function() { | ||
// Writing binary strings was introduced in Node v0.11.14. | ||
@@ -252,2 +252,15 @@ // The test still passes for Node v0.10 and newer v0.11s, so let it be. | ||
// Writing latin1 strings was introduced in v6.4. | ||
// https://github.com/nodejs/node/commit/28071a130e2137bd14d0762a25f0ad83b7a28259 | ||
if (Semver.satisfies(process.version, ">= 6.4")) | ||
it("must write to server from client given latin1", function(done) { | ||
var server; this.mitm.on("connection", function(s) { server = s }) | ||
var client = Net.connect({host: "foo"}) | ||
client.write("Hello", "latin1") | ||
server.setEncoding("latin1") | ||
process.nextTick(function() { server.read().must.equal("Hello") }) | ||
process.nextTick(done) | ||
}) | ||
it("must write to server from client given a buffer", function(done) { | ||
@@ -254,0 +267,0 @@ var server; this.mitm.on("connection", function(s) { server = s }) |
47588
758
4