-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(web): add support for custom headers for web #2459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(web): add support for custom headers for web #2459
Conversation
There was a problem hiding this 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.
web/TrackPlayer/Player.ts
Outdated
private addHeaders(track: Track) { | ||
if (track.headers) { | ||
const networkingEngine = this.player?.getNetworkingEngine(); | ||
networkingEngine?.clearAllRequestFilters(); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
web/TrackPlayer/Player.ts
Outdated
networkingEngine?.clearAllRequestFilters(); | ||
networkingEngine?.registerRequestFilter((type, request) => { | ||
if (type === 0 || type === 1) { | ||
Object.entries(track.headers || {}).forEach(([key, value]) => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
c1c3771
to
d07a681
Compare
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. |
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.