Skip to content

Commit

Permalink
Pass url to RequestModifier.modifyRequestHeader (#3995) (#3996)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkinasiewicz committed Jul 26, 2022
1 parent 1d0f6c7 commit 594767c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion samples/advanced/extend.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/* Extend RequestModifier class and implement our own behaviour */
player.extend("RequestModifier", function () {
return {
modifyRequestHeader: function (xhr) {
modifyRequestHeader: function (xhr, {url}) {
/* Add custom header. Requires to set up Access-Control-Allow-Headers in your */
/* response header in the server side. Reference: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/setRequestHeader */
/* xhr.setRequestHeader('DASH-CUSTOM-HEADER', 'MyValue'); */
Expand Down
2 changes: 2 additions & 0 deletions src/streaming/net/FetchLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ function FetchLoader(cfg) {
setRequestHeader: function (header, value) {
headers.append(header, value);
}
}, {
url: httpRequest.url
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/streaming/net/XHRLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ function XHRLoader(cfg) {
}

if (requestModifier) {
xhr = requestModifier.modifyRequestHeader(xhr);
xhr = requestModifier.modifyRequestHeader(xhr, {
url: httpRequest.url
});
}

if (httpRequest.headers) {
Expand Down
3 changes: 2 additions & 1 deletion src/streaming/utils/RequestModifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function RequestModifier() {
return url;
}

function modifyRequestHeader(request) {
// eslint-disable-next-line no-unused-vars
function modifyRequestHeader(request, {url}) {
return request;
}

Expand Down

0 comments on commit 594767c

Please sign in to comment.