Webhooks: follow redirects on callback calls, up to 10 times

This commit is contained in:
Leonardo Crauss Daronco 2014-11-14 14:26:29 -02:00
parent 536decff7c
commit 8fc251c55b

View File

@ -62,12 +62,13 @@ module.exports = class CallbackEmitter extends EventEmitter
callbackURL += "checksum=#{checksum}"
requestOptions =
followRedirect: true
maxRedirects: 10
uri: callbackURL
method: "POST"
form: data
request requestOptions, (error, response, body) ->
# TODO: treat redirects
if error? or response.statusCode not in [200, 201, 202]
Logger.warn "xx> Error in the callback call to: [#{requestOptions.uri}] for #{simplifiedEvent(data.event)}"
Logger.warn "xx> Error:", error