mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(HTTP Request Node): Respect the original encoding of the incoming response (#9869)
This commit is contained in:
committed by
GitHub
parent
e84ab35c4a
commit
2d19aef540
@@ -1,17 +1,17 @@
|
||||
import { Readable } from 'node:stream';
|
||||
import { createGunzip } from 'node:zlib';
|
||||
import { toBuffer } from '@/BinaryData/utils';
|
||||
import { binaryToBuffer } from '@/BinaryData/utils';
|
||||
|
||||
describe('BinaryData/utils', () => {
|
||||
describe('toBuffer', () => {
|
||||
describe('binaryToBuffer', () => {
|
||||
it('should handle buffer objects', async () => {
|
||||
const body = Buffer.from('test');
|
||||
expect((await toBuffer(body)).toString()).toEqual('test');
|
||||
expect((await binaryToBuffer(body)).toString()).toEqual('test');
|
||||
});
|
||||
|
||||
it('should handle valid uncompressed Readable streams', async () => {
|
||||
const body = Readable.from(Buffer.from('test'));
|
||||
expect((await toBuffer(body)).toString()).toEqual('test');
|
||||
expect((await binaryToBuffer(body)).toString()).toEqual('test');
|
||||
});
|
||||
|
||||
it('should handle valid compressed Readable streams', async () => {
|
||||
@@ -19,13 +19,15 @@ describe('BinaryData/utils', () => {
|
||||
const body = Readable.from(
|
||||
Buffer.from('1f8b08000000000000032b492d2e01000c7e7fd804000000', 'hex'),
|
||||
).pipe(gunzip);
|
||||
expect((await toBuffer(body)).toString()).toEqual('test');
|
||||
expect((await binaryToBuffer(body)).toString()).toEqual('test');
|
||||
});
|
||||
|
||||
it('should throw on invalid compressed Readable streams', async () => {
|
||||
const gunzip = createGunzip();
|
||||
const body = Readable.from(Buffer.from('0001f8b080000000000000000', 'hex')).pipe(gunzip);
|
||||
await expect(toBuffer(body)).rejects.toThrow(new Error('Failed to decompress response'));
|
||||
await expect(binaryToBuffer(body)).rejects.toThrow(
|
||||
new Error('Failed to decompress response'),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user