- Set the default for the stream request option

- throw an error if the user tries to stream with xml
This commit is contained in:
Justin 2018-05-03 10:22:29 -04:00
parent adc1985457
commit a42d9a74dc
2 changed files with 7 additions and 3 deletions

View File

@ -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,

View File

@ -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 });