Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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