Returning 401 Unauthorized from passport

When I tried to login with wrong credentials I was receiving an 'syntax error' from expressjs using passportjs, so I change the code:

lib/middleware/authenticate.js

    res.end(http.STATUS_CODES[res.statusCode]);

to:

    // check if send exists, if yes use it. 
    if (typeof res.send == 'function') {
        res.send(http.STATUS_CODES[res.statusCode]);
      } else {
        res.end(http.STATUS_CODES[res.statusCode]);
      }

I don't know if this is the best way to resolve it, and I don't know if this is the right way to contribute to the project. It's my first time doing this.
I'm sorry my bad english.
Cheers