mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(HTTP Request Node): Follow redirects by default (#5895)
* Redirect as default behaviour * Remove console.logs * Move logic to one single variable * Revert "Redirect as default behaviour" This reverts commit 5b2221b800297865224384eb7f417d72b0d2bbc1. * Redirect as default behaviour inside node structure * Add default behaviour
This commit is contained in:
@@ -748,9 +748,7 @@ export class HttpRequestV3 implements INodeType {
|
|||||||
typeOptions: {
|
typeOptions: {
|
||||||
multipleValues: false,
|
multipleValues: false,
|
||||||
},
|
},
|
||||||
default: {
|
default: { redirect: {} },
|
||||||
redirect: {},
|
|
||||||
},
|
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
displayName: 'Redirect',
|
displayName: 'Redirect',
|
||||||
@@ -779,6 +777,56 @@ export class HttpRequestV3 implements INodeType {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'@version': [1, 2, 3],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Redirects',
|
||||||
|
name: 'redirect',
|
||||||
|
placeholder: 'Add Redirect',
|
||||||
|
type: 'fixedCollection',
|
||||||
|
typeOptions: {
|
||||||
|
multipleValues: false,
|
||||||
|
},
|
||||||
|
default: {
|
||||||
|
redirect: {},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Redirect',
|
||||||
|
name: 'redirect',
|
||||||
|
values: [
|
||||||
|
{
|
||||||
|
displayName: 'Follow Redirects',
|
||||||
|
name: 'followRedirects',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
noDataExpression: true,
|
||||||
|
description: 'Whether to follow all redirects',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Max Redirects',
|
||||||
|
name: 'maxRedirects',
|
||||||
|
type: 'number',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
followRedirects: [true],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: 21,
|
||||||
|
description: 'Max number of redirects to follow',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
displayOptions: {
|
||||||
|
hide: {
|
||||||
|
'@version': [1, 2, 3],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Response',
|
displayName: 'Response',
|
||||||
@@ -984,7 +1032,6 @@ export class HttpRequestV3 implements INodeType {
|
|||||||
'keypair',
|
'keypair',
|
||||||
) as string;
|
) as string;
|
||||||
const jsonHeadersParameter = this.getNodeParameter('jsonHeaders', itemIndex, '') as string;
|
const jsonHeadersParameter = this.getNodeParameter('jsonHeaders', itemIndex, '') as string;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
redirect,
|
redirect,
|
||||||
batching,
|
batching,
|
||||||
@@ -1038,13 +1085,14 @@ export class HttpRequestV3 implements INodeType {
|
|||||||
if (autoDetectResponseFormat || fullResponse) {
|
if (autoDetectResponseFormat || fullResponse) {
|
||||||
requestOptions.resolveWithFullResponse = true;
|
requestOptions.resolveWithFullResponse = true;
|
||||||
}
|
}
|
||||||
|
const defaultRedirect = nodeVersion >= 4 && redirect === undefined;
|
||||||
|
|
||||||
if (redirect?.redirect?.followRedirects) {
|
if (redirect?.redirect?.followRedirects || defaultRedirect) {
|
||||||
requestOptions.followRedirect = true;
|
requestOptions.followRedirect = true;
|
||||||
requestOptions.followAllRedirects = true;
|
requestOptions.followAllRedirects = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redirect?.redirect?.maxRedirects) {
|
if (redirect?.redirect?.maxRedirects || defaultRedirect) {
|
||||||
requestOptions.maxRedirects = redirect?.redirect?.maxRedirects;
|
requestOptions.maxRedirects = redirect?.redirect?.maxRedirects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user