Skip to content

Commit

Permalink
Hotfix/fetch response status code checks (#10)
Browse files Browse the repository at this point in the history
* Add status code checks to fetch commands

Co-authored-by: Craig McEldowney <[email protected]>
  • Loading branch information
craigmc-ottera and craigmc authored Sep 1, 2020
1 parent fc2db0c commit 7f28c1c
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ class HLSVod {
if (!_injectMasterManifest) {
fetch(this.masterManifestUri)
.then(res => {
res.body.pipe(parser);
if (res.status === 200) {
res.body.pipe(parser);
}
else {
throw new Error(res.status + ':: status code error trying to retrieve master manifest ' + masterManifestUri);
}

})
.catch(reject);
} else {
Expand Down Expand Up @@ -253,7 +259,7 @@ class HLSVod {
const targetDuration = this._determineTargetDuration(this.mediaSequences[seqIdx].segments[bw]);
let m3u8 = "#EXTM3U\n";
m3u8 += "#EXT-X-VERSION:6\n";
m3u8 += "#EXT-X-INDEPENDENT-SEGMENTS\n";
m3u8 += "#EXT-X-INDEPENDENT-SEGMENTS\n";
m3u8 += "#EXT-X-TARGETDURATION:" + targetDuration + "\n";
m3u8 += "#EXT-X-MEDIA-SEQUENCE:" + (offset + seqIdx) + "\n";
let discInOffset = discOffset;
Expand Down Expand Up @@ -725,7 +731,12 @@ class HLSVod {
if (!_injectMediaManifest) {
fetch(mediaManifestUri)
.then(res => {
res.body.pipe(parser);
if (res.status === 200) {
res.body.pipe(parser);
}
else {
throw new Error(res.status + ':: status code error trying to retrieve media manifest ' + mediaManifestUri);
}
})
.catch(reject);
} else {
Expand Down Expand Up @@ -776,6 +787,12 @@ class HLSVod {
if (!_injectAudioManifest) {
fetch(audioManifestUri)
.then(res => {
if (res.status === 200) {
res.body.pipe(parser);
}
else {
throw new Error(res.status + ':: status code error trying to retrieve audio manifest ' + audioManifestUri);
}
res.body.pipe(parser);
})
.catch(reject);
Expand Down

0 comments on commit 7f28c1c

Please sign in to comment.