-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Sometimes some apis give algorithm=MD5 in the response headers without quotes which breaks the code with below traceback.
// console output of parts array
realm="MMS Public API"
domain=""
nonce="7hziqlF0xTs4PbKVmzPlEGq0yZRNiFuY"
algorithm=MD5
/Users/hpal/git/sumologic-mongodb-atlas/sumomongodbatlascollector/functions/mongodbatlascollector/sumoutils/node_modules/http-digest-client/http-digest-client.js:107
if (part.length > 2) {
^
TypeError: Cannot read property 'length' of null
at HTTPDigest.parseChallenge [as _parseChallenge] (/Users/hpal/git/sumologic-mongodb-atlas/sumomongodbatlascollector/functions/mongodbatlascollector/sumoutils/node_modules/http-digest-client/http-digest-client.js:107:16)
at HTTPDigest.handleResponse [as _handleResponse] (/Users/hpal/git/sumologic-mongodb-atlas/sumomongodbatlascollector/functions/mongodbatlascollector/sumoutils/node_modules/http-digest-client/http-digest-client.js:39:26)
at ClientRequest.<anonymous> (/Users/hpal/git/sumologic-mongodb-atlas/sumomongodbatlascollector/functions/mongodbatlascollector/sumoutils/node_modules/http-digest-client/http-digest-client.js:29:12)
at Object.onceWrapper (events.js:285:13)
at ClientRequest.emit (events.js:197:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:560:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:113:17)
at TLSSocket.socketOnData (_http_client.js:447:20)
at TLSSocket.emit (events.js:197:13)
at addChunk (_stream_readable.js:288:12)
at line number 106 using the following regex fixes the issue
var part = parts[i].match(/^\s*?([a-zA-Z0-0]+)="(.)"\s?$|^\s*?([a-zA-Z0-0]+)=(.)\s?$/);
Metadata
Metadata
Assignees
Labels
No labels