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
Closes #1317
  • Loading branch information
TheJohnBowers authored and joeyparrish committed Feb 26, 2018
1 parent 61f73bb commit b0f7ba4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1440,15 +1440,21 @@ shaka.dash.DashParser.prototype.requestForTiming_ =
return operation.promise.then((response) => {
let 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);
}

let 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 b0f7ba4

Please sign in to comment.