Skip to content

Commit

Permalink
fix(HTTP Request Node): Errorneous binary object without content-disp…
Browse files Browse the repository at this point in the history
…osition response header (n8n-io#8583)

Co-authored-by: Marcus <marcus@n8n.io>
  • Loading branch information
michael-radency and maspio authored Feb 8, 2024
1 parent de6d466 commit e28b374
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1810,8 +1810,8 @@ export class HttpRequestV3 implements INodeType {
}
}

const responseContentType = response.headers['content-type'] ?? '';
if (autoDetectResponseFormat) {
const responseContentType = response.headers['content-type'] ?? '';
if (responseContentType.includes('application/json')) {
responseFormat = 'json';
if (!response.__bodyResolved) {
Expand Down Expand Up @@ -1890,7 +1890,22 @@ export class HttpRequestV3 implements INodeType {
newItem.json = items[itemIndex].json;
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);
} else if (responseFormat === 'text') {
Expand Down

0 comments on commit e28b374

Please sign in to comment.