Skip to content

Commit

Permalink
Warn if parsing the date from the UTC timing element fails (#1318)
Browse files Browse the repository at this point in the history
Backported to v2.3.x

Closes #1317
  • Loading branch information
TheJohnBowers authored and joeyparrish committed Mar 1, 2018
1 parent 4b1edf6 commit 40a8d97
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1420,15 +1420,23 @@ shaka.dash.DashParser.prototype.requestForTiming_ =
.then(function(response) {
var text;
if (method == 'HEAD') {
if (!response.headers || !response.headers['date']) return 0;
if (!response.headers || !response.headers['date']) {
shaka.log.warning('UTC timing response is missing',
'expected date header');
return 0;
}

text = response.headers['date'];
} else {
text = shaka.util.StringUtils.fromUTF8(response.data);
}

var date = Date.parse(text);
return isNaN(date) ? 0 : (date - Date.now());
if (isNaN(date)) {
shaka.log.warning('Unable to parse date from UTC timing response');
return 0;
}
return (date - Date.now());
});
};

Expand Down

0 comments on commit 40a8d97

Please sign in to comment.