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
f8b2429bd0
commit
ea6646f055
|
@ -85,19 +85,6 @@ exports.run = async function ({ inputs }) {
|
||||||
const request = {
|
const request = {
|
||||||
method: requestMethod,
|
method: requestMethod,
|
||||||
}
|
}
|
||||||
if (
|
|
||||||
requestBody &&
|
|
||||||
requestBody.length !== 0 &&
|
|
||||||
BODY_REQUESTS.indexOf(requestMethod) !== -1
|
|
||||||
) {
|
|
||||||
request.body =
|
|
||||||
typeof requestBody === "string"
|
|
||||||
? requestBody
|
|
||||||
: JSON.stringify(requestBody)
|
|
||||||
request.headers = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
}
|
|
||||||
|
|
||||||
if (headers) {
|
if (headers) {
|
||||||
try {
|
try {
|
||||||
const customHeaders =
|
const customHeaders =
|
||||||
|
@ -110,6 +97,19 @@ exports.run = async function ({ inputs }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
requestBody &&
|
||||||
|
requestBody.length !== 0 &&
|
||||||
|
BODY_REQUESTS.indexOf(requestMethod) !== -1
|
||||||
|
) {
|
||||||
|
request.body =
|
||||||
|
typeof requestBody === "string"
|
||||||
|
? requestBody
|
||||||
|
: JSON.stringify(requestBody)
|
||||||
|
request.headers = {
|
||||||
|
...request.headers,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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