mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
⚡ Small improvements to HTTP Request node
This commit is contained in:
parent
26de4a86c9
commit
cb496b8c4d
|
@ -244,6 +244,26 @@ export class HttpRequest implements INodeType {
|
|||
placeholder: 'Add Option',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Batch Interval',
|
||||
name: 'batchInterval',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0,
|
||||
},
|
||||
default: 1000,
|
||||
description: 'Time (in milliseconds) between each batch of requests. 0 for disabled.',
|
||||
},
|
||||
{
|
||||
displayName: 'Batch Size',
|
||||
name: 'batchSize',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: -1,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Input will be split in batches to throttle requests. -1 for disabled. 0 will be treated as 1.',
|
||||
},
|
||||
{
|
||||
displayName: 'Body Content Type',
|
||||
name: 'bodyContentType',
|
||||
|
@ -278,24 +298,6 @@ export class HttpRequest implements INodeType {
|
|||
default: 'json',
|
||||
description: 'Content-Type to use to send body parameters.',
|
||||
},
|
||||
{
|
||||
displayName: 'MIME Type',
|
||||
name: 'bodyContentCustomMimeType',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'text/xml',
|
||||
description: 'Specify the mime type for raw/custom body type.',
|
||||
required: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/requestMethod': [
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Full Response',
|
||||
name: 'fullResponse',
|
||||
|
@ -317,6 +319,24 @@ export class HttpRequest implements INodeType {
|
|||
default: false,
|
||||
description: 'Succeeds also when status code is not 2xx.',
|
||||
},
|
||||
{
|
||||
displayName: 'MIME Type',
|
||||
name: 'bodyContentCustomMimeType',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'text/xml',
|
||||
description: 'Specify the mime type for raw/custom body type.',
|
||||
required: false,
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/requestMethod': [
|
||||
'PATCH',
|
||||
'POST',
|
||||
'PUT',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Proxy',
|
||||
name: 'proxy',
|
||||
|
@ -335,26 +355,6 @@ export class HttpRequest implements INodeType {
|
|||
default: 10000,
|
||||
description: 'Time in ms to wait for the server to send response headers (and start the response body) before aborting the request.',
|
||||
},
|
||||
{
|
||||
displayName: 'Batch size',
|
||||
name: 'batchSize',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: -1
|
||||
},
|
||||
default: 50,
|
||||
description: 'Input will be split in batches to throttle requests. -1 for disabled. 0 will be treated as 1.',
|
||||
},
|
||||
{
|
||||
displayName: 'Batch interval',
|
||||
name: 'batchInterval',
|
||||
type: 'number',
|
||||
typeOptions: {
|
||||
minValue: 0
|
||||
},
|
||||
default: 1000,
|
||||
description: 'Time (in milliseconds) between each batch of requests. 0 for disabled.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
@ -649,8 +649,8 @@ export class HttpRequest implements INodeType {
|
|||
if (itemIndex > 0 && options.batchSize as number >= 0 && options.batchInterval as number > 0) {
|
||||
// defaults batch size to 1 of it's set to 0
|
||||
const batchSize: number = options.batchSize as number > 0 ? options.batchSize as number : 1;
|
||||
if (itemIndex % batchSize === 0) {
|
||||
await new Promise(resolve => setTimeout(resolve, options.batchInterval as number))
|
||||
if (itemIndex % batchSize === 1) {
|
||||
await new Promise(resolve => setTimeout(resolve, options.batchInterval as number));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue