From 59542d323627047a254fcfe89588d1bc89240e82 Mon Sep 17 00:00:00 2001 From: Bertrand Berthelot Date: Tue, 6 Jun 2023 16:50:50 +0200 Subject: [PATCH] Fix throughput on abort (#4203) * Take account aborted request metrics (for throughput history) * Remove console.log * Fix aborted request timing info * Remove request property checkExistenceOnly, not used anymore --- src/streaming/net/HTTPLoader.js | 23 ++++++++++------------- test/unit/streaming.net.HTTPLoader.js | 6 ++---- test/unit/streaming.net.XHRLoader.js | 20 +++++--------------- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/src/streaming/net/HTTPLoader.js b/src/streaming/net/HTTPLoader.js index 6364cb40db..035e169fc0 100644 --- a/src/streaming/net/HTTPLoader.js +++ b/src/streaming/net/HTTPLoader.js @@ -114,6 +114,11 @@ function HTTPLoader(cfg) { } const addHttpRequestMetric = function(success) { + request.requestStartDate = requestStartTime; + request.requestEndDate = new Date(); + request.firstByteDate = request.firstByteDate || requestStartTime; + request.fileLoaderType = fileLoaderType; + const responseUrl = httpRequest.response ? httpRequest.response.responseURL : null; const responseStatus = httpRequest.response ? httpRequest.response.status : null; const responseHeaders = httpRequest.response && httpRequest.response.getAllResponseHeaders ? httpRequest.response.getAllResponseHeaders() : @@ -127,18 +132,11 @@ function HTTPLoader(cfg) { const handleLoaded = function (success) { needFailureReport = false; - request.requestStartDate = requestStartTime; - request.requestEndDate = new Date(); - request.firstByteDate = request.firstByteDate || requestStartTime; - request.fileLoaderType = fileLoaderType; + addHttpRequestMetric(success); - if (!request.checkExistenceOnly) { - addHttpRequestMetric(success); - - if (request.type === HTTPRequest.MPD_TYPE) { - dashMetrics.addManifestUpdate(request); - eventBus.trigger(Events.MANIFEST_LOADING_FINISHED, { request }); - } + if (request.type === HTTPRequest.MPD_TYPE) { + dashMetrics.addManifestUpdate(request); + eventBus.trigger(Events.MANIFEST_LOADING_FINISHED, { request }); } }; @@ -318,7 +316,6 @@ function HTTPLoader(cfg) { } } - const verb = request.checkExistenceOnly ? HTTPRequest.HEAD : HTTPRequest.GET; const withCredentials = customParametersModel.getXHRWithCredentialsForType(request.type); // Add queryParams that came from pathway cloning @@ -336,7 +333,7 @@ function HTTPLoader(cfg) { httpRequest = { url: modifiedUrl, - method: verb, + method: HTTPRequest.GET, withCredentials: withCredentials, request: request, onload: onload, diff --git a/test/unit/streaming.net.HTTPLoader.js b/test/unit/streaming.net.HTTPLoader.js index 3bff0b4d8f..112e93f273 100644 --- a/test/unit/streaming.net.HTTPLoader.js +++ b/test/unit/streaming.net.HTTPLoader.js @@ -68,7 +68,6 @@ describe('HTTPLoader', function () { httpLoader.load({ request: { - checkExistenceOnly: true, responseType: 'json', type: HTTPRequest.MEDIA_SEGMENT_TYPE, availabilityTimeComplete: false @@ -93,7 +92,7 @@ describe('HTTPLoader', function () { }); httpLoader.load({ - request: {checkExistenceOnly: true}, + request: {}, success: callbackSucceeded, complete: callbackCompleted, error: callbackError @@ -120,7 +119,7 @@ describe('HTTPLoader', function () { }); httpLoader.load({ - request: {checkExistenceOnly: true}, + request: {}, success: callbackSucceeded, complete: callbackCompleted, error: callbackError @@ -149,7 +148,6 @@ describe('HTTPLoader', function () { httpLoader.load({ request: { - checkExistenceOnly: true, responseType: 'arraybuffer', type: HTTPRequest.INIT_SEGMENT_TYPE, availabilityTimeComplete: false diff --git a/test/unit/streaming.net.XHRLoader.js b/test/unit/streaming.net.XHRLoader.js index e2f0b6ddcf..79eda61f83 100644 --- a/test/unit/streaming.net.XHRLoader.js +++ b/test/unit/streaming.net.XHRLoader.js @@ -42,9 +42,7 @@ describe('XHRLoader', function () { requestModifier: requestModifier }); const request = { - request: { - checkExistenceOnly: true - }, + request: {}, onload: callbackSucceeded, onend: callbackCompleted, onerror: callbackError, @@ -70,9 +68,7 @@ describe('XHRLoader', function () { requestModifier: requestModifier }); const request = { - request: { - checkExistenceOnly: true - }, + request: {}, onload: callbackSucceeded, onend: callbackCompleted, onerror: callbackError, @@ -99,9 +95,7 @@ describe('XHRLoader', function () { }); const request = { - request: { - checkExistenceOnly: true - }, + request: {}, onload: callbackSucceeded, onend: callbackCompleted, onerror: callbackError, @@ -127,9 +121,7 @@ describe('XHRLoader', function () { requestModifier: requestModifier }); const request = { - request: { - checkExistenceOnly: true - }, + request: {}, onload: callbackSucceeded, onend: callbackCompleted, onerror: callbackError, @@ -150,9 +142,7 @@ describe('XHRLoader', function () { requestModifier: requestModifier }); const request = { - request: { - checkExistenceOnly: true - }, + request: {}, timeout: 100 }; xhrLoader.load(request);