diff --git a/tests/test-headers.js b/tests/test-headers.js index 773cf863d..0b8777124 100644 --- a/tests/test-headers.js +++ b/tests/test-headers.js @@ -93,12 +93,21 @@ tape('upper-case Host header and redirect', function(t) { // Horrible hack to observe the raw data coming to the server (before Node // core lower-cases the headers) var rawData = '' + s.on('connection', function(socket) { - var ondata = socket.ondata - socket.ondata = function(d, start, end) { - rawData += d.slice(start, end).toString() - return ondata.apply(this, arguments) + if (socket.ondata) { + var ondata = socket.ondata + } + function handledata (d, start, end) { + if (ondata) { + rawData += d.slice(start, end).toString() + return ondata.apply(this, arguments) + } else { + rawData += d + } } + socket.on('data', handledata) + socket.ondata = handledata }) function checkHostHeader(host) { diff --git a/tests/test-localAddress.js b/tests/test-localAddress.js index 4445001d5..1a1723b42 100644 --- a/tests/test-localAddress.js +++ b/tests/test-localAddress.js @@ -9,7 +9,7 @@ tape('bind to invalid address', function(t) { localAddress: '1.2.3.4' }, function(err, res) { t.notEqual(err, null) - t.equal(err.message, 'bind EADDRNOTAVAIL') + t.equal(true, /bind EADDRNOTAVAIL/.test(err.message)) t.equal(res, undefined) t.end() }) diff --git a/tests/test-proxy-connect.js b/tests/test-proxy-connect.js index cc3596874..60e6bab87 100644 --- a/tests/test-proxy-connect.js +++ b/tests/test-proxy-connect.js @@ -52,7 +52,7 @@ tape('proxy', function(t) { t.equal(err, null) t.equal(res.statusCode, 200) t.equal(body, 'derp\n') - t.equal(data, [ + var re = new RegExp([ 'CONNECT google.com:80 HTTP/1.1', 'Proxy-Authorization: Basic dXNlcjpwYXNz', 'dont-send-to-dest: ok', @@ -66,11 +66,9 @@ tape('proxy', function(t) { 'dont-send-to-proxy: ok', 'accept: yo', 'user-agent: just another foobar', - 'host: google.com', - 'Connection: keep-alive', - '', - '' + 'host: google.com' ].join('\r\n')) + t.equal(true, re.test(data)) t.equal(called, true, 'the request must be made to the proxy server') t.end() })