Skip to content

Commit

Permalink
Merge pull request #1426 from request/iojs
Browse files Browse the repository at this point in the history
Fixing tests to pass on io.js and node 0.12 (only test-https.js stiff failing)
  • Loading branch information
simov committed Mar 5, 2015
2 parents a2c9ec7 + 17a0903 commit 210e075
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
17 changes: 13 additions & 4 deletions tests/test-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/test-localAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
8 changes: 3 additions & 5 deletions tests/test-proxy-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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()
})
Expand Down

0 comments on commit 210e075

Please sign in to comment.