fix(HTTP Request Node): Errorneous binary object without content-disposition response header (#8583)

Co-authored-by: Marcus <marcus@n8n.io>
This commit is contained in:
Michael Kret 2024-02-08 18:12:00 +02:00 committed by GitHub
parent de6d466e5e
commit e28b374170
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1810,8 +1810,8 @@ export class HttpRequestV3 implements INodeType {
} }
} }
const responseContentType = response.headers['content-type'] ?? '';
if (autoDetectResponseFormat) { if (autoDetectResponseFormat) {
const responseContentType = response.headers['content-type'] ?? '';
if (responseContentType.includes('application/json')) { if (responseContentType.includes('application/json')) {
responseFormat = 'json'; responseFormat = 'json';
if (!response.__bodyResolved) { if (!response.__bodyResolved) {
@ -1890,7 +1890,22 @@ export class HttpRequestV3 implements INodeType {
newItem.json = items[itemIndex].json; newItem.json = items[itemIndex].json;
binaryData = response; binaryData = response;
} }
newItem.binary![outputPropertyName] = await this.helpers.prepareBinaryData(binaryData); const preparedBinaryData = await this.helpers.prepareBinaryData(
binaryData,
undefined,
responseContentType || undefined,
);
if (
!preparedBinaryData.fileName &&
preparedBinaryData.fileExtension &&
typeof requestOptions.uri === 'string' &&
requestOptions.uri.endsWith(preparedBinaryData.fileExtension)
) {
preparedBinaryData.fileName = requestOptions.uri.split('/').pop();
}
newItem.binary![outputPropertyName] = preparedBinaryData;
returnItems.push(newItem); returnItems.push(newItem);
} else if (responseFormat === 'text') { } else if (responseFormat === 'text') {