Skip to content

Commit

Permalink
Merge pull request #769 from RubenVerborgh/fix-socket-this
Browse files Browse the repository at this point in the history
Fix this pointer on "socket" event
  • Loading branch information
ianwsperber committed Feb 9, 2017
2 parents 1d1cafc + 50859e5 commit 58b04e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/request_overrider.js
Expand Up @@ -193,7 +193,7 @@ function RequestOverrider(req, options, interceptors, remove, cb) {
req.once = req.on = function(event, listener) {
// emit a fake socket.
if (event == 'socket') {
listener(req.socket);
listener.call(req, req.socket);
req.socket.emit('connect', req.socket);
req.socket.emit('secureConnect', req.socket);
}
Expand Down
1 change: 1 addition & 0 deletions tests/test_intercept.js
Expand Up @@ -4212,6 +4212,7 @@ test('request emits socket', function(t) {

var req = http.get('http://gotzsocketz.com');
req.once('socket', function(socket) {
t.equal(this, req);
t.type(socket, Object);
t.type(socket.getPeerCertificate(), 'string');
t.end();
Expand Down

0 comments on commit 58b04e3

Please sign in to comment.