Skip to content

Commit

Permalink
Merge pull request #920 from stephenplusplus/spp--http-parsing-regres…
Browse files Browse the repository at this point in the history
…sion

don't parse an undefined message or body
  • Loading branch information
callmehiphop committed Oct 28, 2015
2 parents f23d3d5 + 96ab971 commit f2508b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ function handleResp(err, resp, body, callback) {
var parsedResp = extend(
true,
{ err: err || null },
util.parseHttpRespMessage(resp),
util.parseHttpRespBody(body)
resp && util.parseHttpRespMessage(resp),
body && util.parseHttpRespBody(body)
);

callback(parsedResp.err, parsedResp.body, parsedResp.resp);
Expand Down
16 changes: 16 additions & 0 deletions test/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,22 @@ describe('common/util', function() {
done();
});
});

it('should not parse undefined response', function(done) {
utilOverrides.parseHttpRespMessage = function() {
done(); // Will throw.
};

util.handleResp(null, null, null, done);
});

it('should not parse undefined body', function(done) {
utilOverrides.parseHttpRespBody = function() {
done(); // Will throw.
};

util.handleResp(null, null, null, done);
});
});

describe('parseHttpRespMessage', function() {
Expand Down

0 comments on commit f2508b3

Please sign in to comment.