Skip to content

Commit

Permalink
fix(HTTP Request Node): Correctly doesn't redirect on non GET method (#…
Browse files Browse the repository at this point in the history
…6132)

Fixed ingnored parameter for redirect
  • Loading branch information
agobrech authored and netroy committed May 15, 2023
1 parent 57d3483 commit e281890
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ 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'] = {
1: new HttpRequestV1(baseDescription),
2: new HttpRequestV2(baseDescription),
3: new HttpRequestV3(baseDescription),
4: new HttpRequestV3(baseDescription),
4.1: new HttpRequestV3(baseDescription),
};

super(nodeVersions, baseDescription);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand All @@ -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 },
Expand Down Expand Up @@ -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) {}
Expand Down

0 comments on commit e281890

Please sign in to comment.