Skip to content

Conversation

michabrem
Copy link

Ensure that custom headers from the track entity are properly applied to HTTP requests in the web implementation. This fix dynamically registers request filters in the Shaka Player's NetworkingEngine.

@michabrem michabrem requested a review from dcvz as a code owner May 4, 2025 12:39
Copy link
Collaborator

@jspizziri jspizziri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michabrem thanks for the PR! left you a couple of questions.

private addHeaders(track: Track) {
if (track.headers) {
const networkingEngine = this.player?.getNetworkingEngine();
networkingEngine?.clearAllRequestFilters();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michabrem , if track 1 has headers, and track 2 does not, wouldn't this result in the headers for track 1 being sent on the .load call of track 2?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I have adjusted that to clear the request filters regardless of header or not, that should do the trick imo.

networkingEngine?.clearAllRequestFilters();
networkingEngine?.registerRequestFilter((type, request) => {
if (type === 0 || type === 1) {
Object.entries(track.headers || {}).forEach(([key, value]) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michabrem it might be more concise to express this like:

request.headers = {
   ...track.headers,
    ...request.headers,
}

I realize this is technically an additional "copy", but it's easier to read IMHO. Thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like that better as well.

Ensure that custom headers from the track entity are properly applied to HTTP requests in the web
implementation. This fix dynamically registers request filters in the Shaka Player's
NetworkingEngine.
@michabrem michabrem force-pushed the fix/web-add-headers-support branch from c1c3771 to d07a681 Compare July 30, 2025 18:31
@michabrem
Copy link
Author

@michabrem thanks for the PR! left you a couple of questions.

thanks, i've finally had the time to come back to this. Tested it locally with my web app and it works with the changes.

@michabrem michabrem requested a review from jspizziri July 30, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants