From 8a882ec0c81a76cda804b67f19cc35f49c8d0c14 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 22 Dec 2024 14:15:41 -0800 Subject: [PATCH 1/2] Set `responseType` to buffer for HTTP requests --- packages/axis-core/src/client.ts | 3 ++- packages/axis-core/test/client.spec.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/axis-core/src/client.ts b/packages/axis-core/src/client.ts index 1e04ec4a..319909ec 100644 --- a/packages/axis-core/src/client.ts +++ b/packages/axis-core/src/client.ts @@ -9,7 +9,8 @@ import { Response } from './Response'; */ export const get = (connection: Connection, relativePath: string): Promise => { const url = connection.url + format(relativePath); - return clientProvider('GET', url, connection.username, connection.password, connection?.options?.agent).get(url); + const client = clientProvider('GET', url, connection.username, connection.password, connection?.options?.agent); + return client.get(url, { responseType: 'buffer' }); }; const format = (relativePath: string): string => { diff --git a/packages/axis-core/test/client.spec.ts b/packages/axis-core/test/client.spec.ts index 780d6bdc..a0f2b92d 100644 --- a/packages/axis-core/test/client.spec.ts +++ b/packages/axis-core/test/client.spec.ts @@ -24,6 +24,7 @@ describe('#get should', () => { // Assert expect(got.statusCode).toBe(200); + expect(got.body).toBeInstanceOf(Buffer); expect(got.body.toString()).toBe('Success'); }); @@ -36,6 +37,7 @@ describe('#get should', () => { // Assert expect(got.statusCode).toBe(200); + expect(got.body).toBeInstanceOf(Buffer); expect(got.body.toString()).toBe('Success'); }); @@ -48,6 +50,7 @@ describe('#get should', () => { // Assert expect(got.statusCode).toBe(200); + expect(got.body).toBeInstanceOf(Buffer); expect(got.body.toString()).toBe('Success'); }); From 844247f59c1486e676292961369f51878dcfead8 Mon Sep 17 00:00:00 2001 From: Mattias Kindborg Date: Fri, 27 Dec 2024 11:11:58 +0100 Subject: [PATCH 2/2] docs(changelog): update --- packages/axis-core/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/axis-core/CHANGELOG.md b/packages/axis-core/CHANGELOG.md index 5d72f735..b71e3e04 100644 --- a/packages/axis-core/CHANGELOG.md +++ b/packages/axis-core/CHANGELOG.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - [BREAKING CHANGE] Deprecate Node.js v21 and below +### :syringe: Fixed + +- [#994](https://github.com/FantasticFiasco/axis-js/pull/994) Fix issue with `get` function not returning the correct response type. (contribution by [@spinda](https://github.com/spinda)) + ### :policeman: Security - Security vulnerability in transient dependency `http-cache-semantics`