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 (#8583)

Co-authored-by: Marcus <[email protected]>
  • Loading branch information
2 people authored and cstuncsik committed Feb 17, 2024
1 parent 4166a83 commit 616cb84
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 616cb84

Please sign in to comment.