mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
feat(WebhookHelpers.ts, Webhook.node.ts): no body response for webhook
no body response for webhook response. This may be helpful if certain services require that a response doesn't have a body
This commit is contained in:
parent
ce9cca82b1
commit
d1290075ed
|
@ -204,7 +204,14 @@ export async function executeWebhook(
|
||||||
200,
|
200,
|
||||||
) as number;
|
) as number;
|
||||||
|
|
||||||
if (!['onReceived', 'lastNode', 'responseNode'].includes(responseMode as string)) {
|
if (
|
||||||
|
![
|
||||||
|
'onReceived',
|
||||||
|
'lastNode',
|
||||||
|
'responseNode',
|
||||||
|
'noBodyResponse'
|
||||||
|
].includes(responseMode as string)
|
||||||
|
) {
|
||||||
// If the mode is not known we error. Is probably best like that instead of using
|
// If the mode is not known we error. Is probably best like that instead of using
|
||||||
// the default that people know as early as possible (probably already testing phase)
|
// the default that people know as early as possible (probably already testing phase)
|
||||||
// that something does not resolve properly.
|
// that something does not resolve properly.
|
||||||
|
@ -349,6 +356,17 @@ export async function executeWebhook(
|
||||||
didSendResponse = true;
|
didSendResponse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Some systems require that a webhook doesn't respond with any data
|
||||||
|
// if responseMode is set to noBodyResponse we will see this fire
|
||||||
|
if (responseMode === 'noBodyResponse' && !didSendResponse) {
|
||||||
|
// Return response without data
|
||||||
|
responseCallback(null, {
|
||||||
|
responseCode,
|
||||||
|
});
|
||||||
|
|
||||||
|
didSendResponse = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the data of the webhook node
|
// Initialize the data of the webhook node
|
||||||
const nodeExecutionStack: IExecuteData[] = [];
|
const nodeExecutionStack: IExecuteData[] = [];
|
||||||
nodeExecutionStack.push({
|
nodeExecutionStack.push({
|
||||||
|
|
|
@ -165,6 +165,11 @@ export class Webhook implements INodeType {
|
||||||
value: 'responseNode',
|
value: 'responseNode',
|
||||||
description: 'Response defined in that node',
|
description: 'Response defined in that node',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'No Body Response',
|
||||||
|
value: 'noBodyResponse',
|
||||||
|
description: 'Returns data without a body',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
default: 'onReceived',
|
default: 'onReceived',
|
||||||
description: 'When and how to respond to the webhook.',
|
description: 'When and how to respond to the webhook.',
|
||||||
|
|
Loading…
Reference in a new issue