Skip to content
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

Disable "age" header check with lowLatencyMode #3685

Merged
merged 5 commits into from Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/loader/playlist-loader.ts
Expand Up @@ -70,8 +70,6 @@ class PlaylistLoader {
[key: string]: Loader<LoaderContext>;
} = Object.create(null);

private checkAgeHeader: boolean = true;

constructor(hls: Hls) {
this.hls = hls;
this.registerListeners();
Expand Down Expand Up @@ -148,7 +146,6 @@ class PlaylistLoader {
data: ManifestLoadingData
) {
const { url } = data;
this.checkAgeHeader = true;
this.load({
id: null,
groupId: null,
Expand Down Expand Up @@ -686,13 +683,10 @@ class PlaylistLoader {
return;
}

// Avoid repeated browser error log `Refused to get unsafe header "age"` when unnecessary or past attempts failed
const checkAgeHeader = this.checkAgeHeader && levelDetails.live;
const ageHeader: string | null = checkAgeHeader
? loader.getResponseHeader('age')
: null;
levelDetails.ageHeader = ageHeader ? parseFloat(ageHeader) : 0;
this.checkAgeHeader = !!ageHeader;
if (levelDetails.live) {
const ageHeader = loader.getResponseHeader('age');
levelDetails.ageHeader = ageHeader ? parseFloat(ageHeader) : 0;
}

switch (type) {
case PlaylistContextType.MANIFEST:
Expand Down
8 changes: 2 additions & 6 deletions src/utils/xhr-loader.ts
Expand Up @@ -250,12 +250,8 @@ class XhrLoader implements Loader<LoaderContext> {
}

getResponseHeader(name: string): string | null {
if (this.loader) {
try {
return this.loader.getResponseHeader(name);
} catch (error) {
/* Could not get headers */
}
if (this.loader && this.loader.getAllResponseHeaders().indexOf(name) >= 0) {
return this.loader.getResponseHeader(name);
}
return null;
}
Expand Down