fix(HTTP Request Node): Correctly doesn't redirect on non GET method (#6132)

Fixed ingnored parameter for redirect
This commit is contained in:
agobrech 2023-05-04 09:55:35 +02:00 committed by GitHub
parent 5d77ec76e3
commit 3f5c606254
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -14,7 +14,7 @@ export class HttpRequest extends VersionedNodeType {
group: ['output'],
subtitle: '={{$parameter["requestMethod"] + ": " + $parameter["url"]}}',
description: 'Makes an HTTP request and returns the response data',
defaultVersion: 4,
defaultVersion: 4.1,
};
const nodeVersions: IVersionedNodeType['nodeVersions'] = {
@ -22,6 +22,7 @@ export class HttpRequest extends VersionedNodeType {
2: new HttpRequestV2(baseDescription),
3: new HttpRequestV3(baseDescription),
4: new HttpRequestV3(baseDescription),
4.1: new HttpRequestV3(baseDescription),
};
super(nodeVersions, baseDescription);

View file

@ -39,7 +39,7 @@ export class HttpRequestV3 implements INodeType {
this.description = {
...baseDescription,
subtitle: '={{$parameter["method"] + ": " + $parameter["url"]}}',
version: [3, 4],
version: [3, 4, 4.1],
defaults: {
name: 'HTTP Request',
color: '#2200DD',
@ -1104,6 +1104,11 @@ export class HttpRequestV3 implements INodeType {
if (autoDetectResponseFormat || fullResponse) {
requestOptions.resolveWithFullResponse = true;
}
if (requestOptions.method !== 'GET' && nodeVersion >= 4.1) {
requestOptions = { ...requestOptions, followAllRedirects: false };
}
const defaultRedirect = nodeVersion >= 4 && redirect === undefined;
if (redirect?.redirect?.followRedirects || defaultRedirect) {
@ -1129,7 +1134,6 @@ export class HttpRequestV3 implements INodeType {
// set default timeout to 1 hour
requestOptions.timeout = 3600000;
}
if (sendQuery && queryParameterArrays) {
Object.assign(requestOptions, {
qsStringifyOptions: { arrayFormat: queryParameterArrays },
@ -1346,7 +1350,6 @@ export class HttpRequestV3 implements INodeType {
'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7';
}
}
try {
this.sendMessageToUI(sanitizeUiMessage(requestOptions, authDataKeys));
} catch (e) {}