Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'callback is not a function' #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ var makeRequest = function(method, options, params, callback, pipeTarget) {
: $(null, res, body);
}

var type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);
var type2msg;
try {
type2msg = ntlm.parseType2Message(res.headers['www-authenticate']);
}
catch (ex) {
return $(ex);
}

var type3msg = ntlm.createType3Message(type2msg, options);
options.method = method;
_.extend(options.headers, {
Expand Down
6 changes: 3 additions & 3 deletions lib/ntlm.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ function createType1Message(options){
return 'NTLM ' + buf.toString('base64');
}

function parseType2Message(rawmsg, callback){
function parseType2Message(rawmsg){
var match = rawmsg.match(/NTLM (.+)?/);
if(!match || !match[1])
return callback(new Error("Couldn't find NTLM in the message type2 comming from the server"));
throw new Error("Couldn't find NTLM in the message type2 comming from the server");

var buf = new Buffer(match[1], 'base64');

Expand All @@ -113,7 +113,7 @@ function parseType2Message(rawmsg, callback){
msg.type = buf.readInt16LE(8);

if(msg.type != 2)
return callback(new Error("Server didn't return a type 2 message"));
throw new Error("Server didn't return a type 2 message");

msg.targetNameLen = buf.readInt16LE(12);
msg.targetNameMaxLen = buf.readInt16LE(14);
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
],
"license": "ISC",
"dependencies": {
"agentkeepalive": "^2.0.3",
"async": "^0.7.0",
"lodash": "^2.4.1",
"request": "^2.34.0"
"agentkeepalive": "^4.1.3",
"async": "^3.2.0",
"lodash": "^4.17.20",
"request": "^2.88.2"
},
"devDependencies": {
"coveralls": "*",
Expand Down