mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix(HTTP Request Node): Always lowercase headers
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
replaceNullValues,
|
||||
sanitizeUiMessage,
|
||||
} from '../GenericFunctions';
|
||||
import { keysToLowercase } from '../../../utils/utilities';
|
||||
|
||||
function toText<T>(data: T) {
|
||||
if (typeof data === 'object' && data !== null) {
|
||||
@@ -1033,17 +1034,21 @@ export class HttpRequestV3 implements INodeType {
|
||||
const body = this.getNodeParameter('body', itemIndex, '') as string;
|
||||
|
||||
const sendHeaders = this.getNodeParameter('sendHeaders', itemIndex, false) as boolean;
|
||||
|
||||
const headerParameters = this.getNodeParameter(
|
||||
'headerParameters.parameters',
|
||||
itemIndex,
|
||||
[],
|
||||
) as [{ name: string; value: string }];
|
||||
|
||||
const specifyHeaders = this.getNodeParameter(
|
||||
'specifyHeaders',
|
||||
itemIndex,
|
||||
'keypair',
|
||||
) as string;
|
||||
|
||||
const jsonHeadersParameter = this.getNodeParameter('jsonHeaders', itemIndex, '') as string;
|
||||
|
||||
const {
|
||||
redirect,
|
||||
batching,
|
||||
@@ -1221,8 +1226,8 @@ export class HttpRequestV3 implements INodeType {
|
||||
requestOptions.body = uploadData;
|
||||
requestOptions.headers = {
|
||||
...requestOptions.headers,
|
||||
'Content-Length': contentLength,
|
||||
'Content-Type': itemBinaryData.mimeType ?? 'application/octet-stream',
|
||||
'content-length': contentLength,
|
||||
'content-type': itemBinaryData.mimeType ?? 'application/octet-stream',
|
||||
};
|
||||
} else if (bodyContentType === 'raw') {
|
||||
requestOptions.body = body;
|
||||
@@ -1253,8 +1258,9 @@ export class HttpRequestV3 implements INodeType {
|
||||
|
||||
// Get parameters defined in the UI
|
||||
if (sendHeaders && headerParameters) {
|
||||
let additionalHeaders: IDataObject = {};
|
||||
if (specifyHeaders === 'keypair') {
|
||||
requestOptions.headers = headerParameters.reduce(parametersToKeyValue, {});
|
||||
additionalHeaders = headerParameters.reduce(parametersToKeyValue, {});
|
||||
} else if (specifyHeaders === 'json') {
|
||||
// body is specified using JSON
|
||||
try {
|
||||
@@ -1269,8 +1275,12 @@ export class HttpRequestV3 implements INodeType {
|
||||
);
|
||||
}
|
||||
|
||||
requestOptions.headers = jsonParse(jsonHeadersParameter);
|
||||
additionalHeaders = jsonParse(jsonHeadersParameter);
|
||||
}
|
||||
requestOptions.headers = {
|
||||
...requestOptions.headers,
|
||||
...keysToLowercase(additionalHeaders),
|
||||
};
|
||||
}
|
||||
|
||||
if (autoDetectResponseFormat || responseFormat === 'file') {
|
||||
@@ -1290,7 +1300,7 @@ export class HttpRequestV3 implements INodeType {
|
||||
requestOptions.headers = {};
|
||||
}
|
||||
const rawContentType = this.getNodeParameter('rawContentType', itemIndex) as string;
|
||||
requestOptions.headers['Content-Type'] = rawContentType;
|
||||
requestOptions.headers['content-type'] = rawContentType;
|
||||
}
|
||||
|
||||
const authDataKeys: IAuthDataSanitizeKeys = {};
|
||||
@@ -1338,7 +1348,6 @@ export class HttpRequestV3 implements INodeType {
|
||||
try {
|
||||
this.sendMessageToUI(sanitizeUiMessage(requestOptions, authDataKeys));
|
||||
} catch (e) {}
|
||||
|
||||
if (authentication === 'genericCredentialType' || authentication === 'none') {
|
||||
if (oAuth1Api) {
|
||||
const requestOAuth1 = this.helpers.requestOAuth1.call(this, 'oAuth1Api', requestOptions);
|
||||
|
||||
Reference in New Issue
Block a user