From a42d9a74dcfbb09f7f4ab4da92a1517a07d3a6cb Mon Sep 17 00:00:00 2001 From: Justin Date: Thu, 3 May 2018 10:22:29 -0400 Subject: [PATCH] - Set the default for the stream request option - throw an error if the user tries to stream with xml --- src/infrastructure/RequestHelper.js | 8 ++++++-- src/services/Jobs.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/infrastructure/RequestHelper.js b/src/infrastructure/RequestHelper.js index 1585e978..21bc82e9 100644 --- a/src/infrastructure/RequestHelper.js +++ b/src/infrastructure/RequestHelper.js @@ -30,8 +30,12 @@ function defaultRequest( } class RequestHelper { - static async get(service, endpoint, options = {}, requestOptions = {}) { - if (requestOptions && requestOptions.stream === true) { + static async get(service, endpoint, options = {}, { stream = false } = {}) { + if (stream) { + if(service.useXMLHttpRequest){ + throw new Error('Cannot use streaming functionality with XMLHttpRequest. Please instantiate without this option to use streaming'); + } + return StreamableRequest.get(defaultRequest(service, endpoint, { headers: service.headers, qs: options, diff --git a/src/services/Jobs.js b/src/services/Jobs.js index fc781ca8..b7861958 100644 --- a/src/services/Jobs.js +++ b/src/services/Jobs.js @@ -13,7 +13,7 @@ class Jobs extends BaseService { return RequestHelper.post(this, `projects/${pId}/jobs/${jobId}/play`); } - downloadSingleArtifactFile(projectId, jobId, artifactPath, { stream = false }) { + downloadSingleArtifactFile(projectId, jobId, artifactPath, { stream }) { const pId = encodeURIComponent(projectId); return RequestHelper.get(this, `projects/${pId}/jobs/${jobId}/artifacts/${artifactPath}`, {}, { stream });