Skip to content

Commit

Permalink
Update httpResponseChecker.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pacmano1 authored Aug 28, 2024
1 parent b2de9fd commit a26f4de
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions httpResponseChecker.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
try {
msg = JSON.parse(msg) // we are going to reset msg to be its value in JSON here.
$c('isJSONresponse', true)
$co('isJSONresponse', true)
} catch (e) { // we have an empty msg or some other non-JSON response
$c('isJSONresponse', false)
$co('isJSONresponse', false)
}

var responseStatusLine = $('responseStatusLine');
var responseCode = parseInt(responseStatusLine.split(' ')[1], 10);

if ( responseCode == 200) { // we have an entirely successful message (note no check on isJSON, buyer beware)
$c('API_Post_OK',true)
$co('API_Post_OK',true)
process_results();
} else { // we either have an entirely bad post (endpoint not answering OR we have a JSON error)
if ($c('isJSONresponse') == true) { // do not retry, just collect the JSON stuff
if ($co('isJSONresponse') == true) { // do not retry, just collect the JSON stuff
responseStatus = SENT
bad_call_error_handler(JSON.stringify(msg))
} else { // Let's retry a few times
if (connectorMessage.getSendAttempts() <= 2) { // try a few times
responseStatus = QUEUED //
} else { // exceeded the tries
responseStatus = SENT
$c('API_Post_OK',false)
$co('API_Post_OK',false)
bad_call_error_handler(msg) // we have tried this post a few times, responseStatus will already be ERROR, so just send the alert
}
}
Expand Down

0 comments on commit a26f4de

Please sign in to comment.