|
|
@@ -44,7 +44,7 @@ const configSchema = {
|
|
|
headers: {
|
|
|
type: 'object',
|
|
|
title: 'Extra Headers',
|
|
|
- description: 'Additional response headers',
|
|
|
+ description: 'Additional response headers. A content-type entry here is ignored; use the Content Type field above instead',
|
|
|
additionalProperties: { type: 'string' }
|
|
|
}
|
|
|
}
|
|
|
@@ -80,6 +80,10 @@ async function execute(config, input, context) {
|
|
|
let body;
|
|
|
if (source === 'input') {
|
|
|
body = smartbotic.utils.getFieldValue(input, config.bodyField || 'data');
|
|
|
+ if (body === undefined) {
|
|
|
+ throw new Error('Respond to Webhook: nothing found at "' +
|
|
|
+ (config.bodyField || 'data') + '" to send as the body');
|
|
|
+ }
|
|
|
} else if (source === 'text') {
|
|
|
body = config.body === undefined || config.body === null ? '' : String(config.body);
|
|
|
} else {
|
|
|
@@ -99,6 +103,12 @@ async function execute(config, input, context) {
|
|
|
const headers = {};
|
|
|
if (config.headers && typeof config.headers === 'object') {
|
|
|
for (const name of Object.keys(config.headers)) {
|
|
|
+ // A header named content-type in any casing would otherwise survive
|
|
|
+ // alongside the canonical one, and which of the two reaches the
|
|
|
+ // client would come down to key ordering rather than intent.
|
|
|
+ if (name.toLowerCase() === 'content-type') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
headers[name] = String(config.headers[name]);
|
|
|
}
|
|
|
}
|