From d5405b591814f1f23c0c67ca58085bd4abe0e34c Mon Sep 17 00:00:00 2001 From: Dustin Popp Date: Tue, 22 Sep 2020 16:54:03 -0500 Subject: [PATCH] feat: upgrade axios and re-enable gzipping responses --- lib/request-wrapper.ts | 5 +---- package-lock.json | 36 ++++++++----------------------- package.json | 2 +- test/unit/request-wrapper.test.js | 8 +++---- 4 files changed, 15 insertions(+), 36 deletions(-) diff --git a/lib/request-wrapper.ts b/lib/request-wrapper.ts index 8a6792449..7ffc8bc81 100644 --- a/lib/request-wrapper.ts +++ b/lib/request-wrapper.ts @@ -202,11 +202,8 @@ export class RequestWrapper { headers = extend(true, {}, headers, multipartForm.getHeaders()); } - // TEMPORARY: Disabling gzipping due to bug in axios until fix is released: - // https://github.com/axios/axios/pull/1129 - // accept gzip encoded responses if Accept-Encoding is not already set - // headers['Accept-Encoding'] = headers['Accept-Encoding'] || 'gzip'; + headers['Accept-Encoding'] = headers['Accept-Encoding'] || 'gzip'; const requestParams = { url, diff --git a/package-lock.json b/package-lock.json index b82cf31a4..b40eced0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2409,12 +2409,11 @@ "dev": true }, "axios": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz", - "integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==", + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz", + "integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==", "requires": { - "follow-redirects": "1.5.10", - "is-buffer": "^2.0.2" + "follow-redirects": "^1.10.0" } }, "axios-cookiejar-support": { @@ -4459,22 +4458,9 @@ } }, "follow-redirects": { - "version": "1.5.10", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", - "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", - "requires": { - "debug": "=3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } - } - } + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz", + "integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==" }, "for-in": { "version": "1.0.2", @@ -5114,11 +5100,6 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, - "is-buffer": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", - "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==" - }, "is-callable": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", @@ -8517,7 +8498,8 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true }, "mute-stream": { "version": "0.0.7", diff --git a/package.json b/package.json index 69619711b..9f80a597d 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@types/isstream": "^0.1.0", "@types/node": "~10.14.19", "@types/tough-cookie": "^4.0.0", - "axios": "^0.18.1", + "axios": "^0.20.0", "axios-cookiejar-support": "^1.0.0", "camelcase": "^5.3.1", "debug": "^4.1.1", diff --git a/test/unit/request-wrapper.test.js b/test/unit/request-wrapper.test.js index 03b7badbb..3c8651fcf 100644 --- a/test/unit/request-wrapper.test.js +++ b/test/unit/request-wrapper.test.js @@ -152,7 +152,7 @@ describe('sendRequest', () => { 'https://example.ibm.com/v1/environments/environment-id/configurations/configuration-id' ); expect(mockAxiosInstance.mock.calls[0][0].headers).toEqual({ - // 'Accept-Encoding': 'gzip', + 'Accept-Encoding': 'gzip', 'test-header': 'test-header-value', }); expect(mockAxiosInstance.mock.calls[0][0].method).toEqual(parameters.defaultOptions.method); @@ -267,7 +267,7 @@ describe('sendRequest', () => { 'https://example.ibm.com/v1/environments/environment-id/configurations/configuration-id' ); expect(mockAxiosInstance.mock.calls[0][0].headers).toEqual({ - // 'Accept-Encoding': 'gzip', + 'Accept-Encoding': 'gzip', 'test-header': 'override-header-value', 'add-header': 'add-header-value', }); @@ -319,7 +319,7 @@ describe('sendRequest', () => { 'https://example.ibm.com/v1/environments' ); expect(mockAxiosInstance.mock.calls[0][0].headers).toEqual({ - // 'Accept-Encoding': 'gzip', + 'Accept-Encoding': 'gzip', 'test-header': 'test-header-value', 'add-header': 'add-header-value', }); @@ -387,7 +387,7 @@ describe('sendRequest', () => { 'https://example.ibm.com/v1/environments/environment-id/configurations/configuration-id' ); expect(mockAxiosInstance.mock.calls[0][0].headers).toMatchObject({ - // 'Accept-Encoding': 'gzip', + 'Accept-Encoding': 'gzip', 'test-header': 'override-header-value', 'add-header': 'add-header-value', });