From bc37793da9e6c5ae3fcbd5205640db7afeed7c0a Mon Sep 17 00:00:00 2001 From: Barna Magyarkuti Date: Mon, 29 Jan 2018 16:09:21 +0100 Subject: [PATCH] fix(requestOption): stop caching headers caching caused the x-ems-header to get out of date --- lib/requestOption.js | 2 +- lib/requestOption.spec.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/requestOption.js b/lib/requestOption.js index f82e653..8bf4c8c 100644 --- a/lib/requestOption.js +++ b/lib/requestOption.js @@ -89,7 +89,7 @@ class SuiteRequestOption { const hash = { port: this.port, host: this.host, - headers: this.headers, + headers: this.headers.slice(0), prefix: this.prefix, timeout: this.timeout, maxContentLength: this.maxContentLength diff --git a/lib/requestOption.spec.js b/lib/requestOption.spec.js index 55e5630..f27daa6 100644 --- a/lib/requestOption.spec.js +++ b/lib/requestOption.spec.js @@ -137,6 +137,12 @@ describe('SuiteRequestOption', function() { expect(requestOptions.toHash()).to.have.property('allowEmptyResponse', true); }); + + it('should not cache headers', function() { + const requestOptions = new SuiteRequestOption(dummyServiceConfig.host, dummyServiceConfig); + requestOptions.toHash().headers.push('from_test'); + expect(requestOptions.toHash().headers).not.to.include('from_test'); + }); }); });