Fixing #3237 and #3235 - always apply headers on out going webhooks if they are specified and handle a range of response codes.
This commit is contained in:
parent
aebd39d874
commit
62613f6a74
|
@ -85,6 +85,18 @@ exports.run = async function ({ inputs }) {
|
||||||
const request = {
|
const request = {
|
||||||
method: requestMethod,
|
method: requestMethod,
|
||||||
}
|
}
|
||||||
|
if (headers) {
|
||||||
|
try {
|
||||||
|
const customHeaders =
|
||||||
|
typeof headers === "string" ? JSON.parse(headers) : headers
|
||||||
|
request.headers = { ...request.headers, ...customHeaders }
|
||||||
|
} catch (err) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
response: "Unable to process headers, must be a JSON object.",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
requestBody &&
|
requestBody &&
|
||||||
requestBody.length !== 0 &&
|
requestBody.length !== 0 &&
|
||||||
|
@ -95,21 +107,9 @@ exports.run = async function ({ inputs }) {
|
||||||
? requestBody
|
? requestBody
|
||||||
: JSON.stringify(requestBody)
|
: JSON.stringify(requestBody)
|
||||||
request.headers = {
|
request.headers = {
|
||||||
|
...request.headers,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headers) {
|
|
||||||
try {
|
|
||||||
const customHeaders =
|
|
||||||
typeof headers === "string" ? JSON.parse(headers) : headers
|
|
||||||
request.headers = { ...request.headers, ...customHeaders }
|
|
||||||
} catch (err) {
|
|
||||||
return {
|
|
||||||
success: false,
|
|
||||||
response: "Unable to process headers, must be a JSON object.",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -122,7 +122,7 @@ exports.run = async function ({ inputs }) {
|
||||||
return {
|
return {
|
||||||
httpStatus: status,
|
httpStatus: status,
|
||||||
response: message,
|
response: message,
|
||||||
success: status === 200,
|
success: status >= 200 && status <= 206,
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
|
|
Loading…
Reference in New Issue