From e96f7cecfc8f1367ea6255363d926472ddda793a Mon Sep 17 00:00:00 2001 From: Daniel Silhavy Date: Thu, 21 Mar 2024 15:14:05 +0100 Subject: [PATCH] Fix a bug in the CommonAccessTokenController.js that leads to null values for the token. (#4434) --- src/streaming/controllers/CommonAccessTokenController.js | 8 ++++++-- src/streaming/net/HTTPLoader.js | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/streaming/controllers/CommonAccessTokenController.js b/src/streaming/controllers/CommonAccessTokenController.js index 8847bc2f5d..334f4f0c73 100644 --- a/src/streaming/controllers/CommonAccessTokenController.js +++ b/src/streaming/controllers/CommonAccessTokenController.js @@ -44,8 +44,12 @@ function CommonAccessTokenController() { } const commonAccessTokenHeader = httpResponse.headers[Constants.COMMON_ACCESS_TOKEN_HEADER] - const host = Utils.getHostFromUrl(httpResponse.request.url) - hostTokenMap[host] = commonAccessTokenHeader + if (commonAccessTokenHeader) { + const host = Utils.getHostFromUrl(httpResponse.request.url) + if (host) { + hostTokenMap[host] = commonAccessTokenHeader + } + } } function getCommonAccessTokenForUrl(url) { diff --git a/src/streaming/net/HTTPLoader.js b/src/streaming/net/HTTPLoader.js index 8b79af2f7e..20366e2454 100644 --- a/src/streaming/net/HTTPLoader.js +++ b/src/streaming/net/HTTPLoader.js @@ -249,7 +249,7 @@ function HTTPLoader(cfg) { if (aborted) { if (config.abort) { config.abort(requestObject); - } + } return; } @@ -285,13 +285,13 @@ function HTTPLoader(cfg) { }; - const _updateRequestTimingInfo = function() { + const _updateRequestTimingInfo = function () { requestObject.startDate = requestStartTime; requestObject.endDate = new Date(); requestObject.firstByteDate = requestObject.firstByteDate || requestStartTime; } - const _updateResourceTimingInfo = function() { + const _updateResourceTimingInfo = function () { httpResponse.resourceTiming.responseEnd = Date.now(); // If enabled the ResourceTimingApi we add the corresponding information to the request object. @@ -315,7 +315,7 @@ function HTTPLoader(cfg) { }); }); } - + /** * Retriggers the request in case we did not exceed the number of retry attempts * @private