Skip to content

Commit

Permalink
test: remoteAddress may be undefined
Browse files Browse the repository at this point in the history
see nodejs/node#4198

test case:
``` javascript
var net = require('net');
var server = net.createServer(function(c) { //'connection' listener
  c.on('end', function() {
    console.log(c.remoteAddress);
    server.close();
  });
});
server.listen(8124, function() {
  var client = net.connect({port: 8124}, function(c) {
    client.end();
  });
});
```

Signed-off-by: Arthur Gautier <baloo@gandi.net>
  • Loading branch information
Arthur Gautier committed Dec 9, 2015
1 parent d125b19 commit fece5e2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ describe('forwarded(req)', function () {
})
assert.deepEqual(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2'])
})

it('should parse headers with disconnected client', function () {
var req = createReq(undefined, {
'x-forwarded-for': '10.0.0.2,, 10.0.0.1'
})
assert.deepEqual(forwarded(req), ['10.0.0.1', '10.0.0.2'])
})
})

function createReq(socketAddr, headers) {
Expand Down

0 comments on commit fece5e2

Please sign in to comment.