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:
agobrech 2023-04-05 15:37:14 +02:00 committed by GitHub
parent 33c67f45ba
commit f7e610b15c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -748,9 +748,7 @@ export class HttpRequestV3 implements INodeType {
typeOptions: {
multipleValues: false,
},
default: {
redirect: {},
},
default: { redirect: {} },
options: [
{
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',
@ -984,7 +1032,6 @@ export class HttpRequestV3 implements INodeType {
'keypair',
) as string;
const jsonHeadersParameter = this.getNodeParameter('jsonHeaders', itemIndex, '') as string;
const {
redirect,
batching,
@ -1038,13 +1085,14 @@ export class HttpRequestV3 implements INodeType {
if (autoDetectResponseFormat || fullResponse) {
requestOptions.resolveWithFullResponse = true;
}
const defaultRedirect = nodeVersion >= 4 && redirect === undefined;
if (redirect?.redirect?.followRedirects) {
if (redirect?.redirect?.followRedirects || defaultRedirect) {
requestOptions.followRedirect = true;
requestOptions.followAllRedirects = true;
}
if (redirect?.redirect?.maxRedirects) {
if (redirect?.redirect?.maxRedirects || defaultRedirect) {
requestOptions.maxRedirects = redirect?.redirect?.maxRedirects;
}