diff --git a/lib/net/networking_utils.js b/lib/net/networking_utils.js index 0481b025cd..f76b2ad630 100644 --- a/lib/net/networking_utils.js +++ b/lib/net/networking_utils.js @@ -8,6 +8,7 @@ goog.provide('shaka.net.NetworkingUtils'); goog.require('goog.Uri'); goog.require('shaka.net.NetworkingEngine'); +goog.require('shaka.util.Error'); /** @@ -30,13 +31,21 @@ shaka.net.NetworkingUtils = class { const type = shaka.net.NetworkingEngine.RequestType.MANIFEST; const request = shaka.net.NetworkingEngine.makeRequest([uri], retryParams); - request.method = 'HEAD'; - const response = await netEngine.request(type, request).promise; + try { + request.method = 'HEAD'; + const response = await netEngine.request(type, request).promise; + mimeType = response.headers['content-type']; + } catch (error) { + if (error && error.code == shaka.util.Error.Code.HTTP_ERROR) { + request.method = 'GET'; + const response = await netEngine.request(type, request).promise; + mimeType = response.headers['content-type']; + } + } // https://bit.ly/2K9s9kf says this header should always be available, // but just to be safe: - mimeType = response.headers['content-type']; return mimeType ? mimeType.toLowerCase().split(';').shift() : ''; }