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

For each call to fetch, set the User-Agent header #1234

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/DOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ class HTMLLinkElement extends HTMLLoadableElement {
const url = _mapUrl(this.href, this.ownerDocument.defaultView);

return this.ownerDocument.resources.addResource((onprogress, cb) => {
this.ownerDocument.defaultView.fetch(url)
this.ownerDocument.defaultView.fetch(url, {headers: {'user-agent': `User-Agent: ${this.ownerDocument.defaultView.navigator.userAgent}`}})
.then(res => {
if (res.status >= 200 && res.status < 300) {
return res.text();
Expand Down Expand Up @@ -1811,7 +1811,7 @@ class HTMLScriptElement extends HTMLLoadableElement {
const url = _mapUrl(this.src, this.ownerDocument.defaultView);

return this.ownerDocument.resources.addResource((onprogress, cb) => {
this.ownerDocument.defaultView.fetch(url)
this.ownerDocument.defaultView.fetch(url, {headers: {'user-agent': `User-Agent: ${this.ownerDocument.defaultView.navigator.userAgent}`}})
.then(res => {
if (res.status >= 200 && res.status < 300) {
return res.text();
Expand Down Expand Up @@ -2171,7 +2171,7 @@ class HTMLIFrameElement extends HTMLSrcableElement {
throw new Error('iframe owner document does not have a WebGL context');
}
} else {
const res = await this.ownerDocument.defaultView.fetch(url);
const res = await this.ownerDocument.defaultView.fetch(url, {headers: {'user-agent': `User-Agent: ${this.ownerDocument.defaultView.navigator.userAgent}`}});
if (this.epoch !== localEpoch) {
return;
}
Expand Down Expand Up @@ -2785,7 +2785,7 @@ class HTMLImageElement extends HTMLSrcableElement {
const src = value;

this.ownerDocument.resources.addResource((onprogress, cb) => {
this.ownerDocument.defaultView.fetch(src)
this.ownerDocument.defaultView.fetch(src, {headers: {'user-agent': `User-Agent: ${this.ownerDocument.defaultView.navigator.userAgent}`}})
.then(res => {
if (res.status >= 200 && res.status < 300) {
return res.arrayBuffer();
Expand Down Expand Up @@ -2915,7 +2915,7 @@ class HTMLAudioElement extends HTMLMediaElement {
const src = value;

this.ownerDocument.resources.addResource((onprogress, cb) => {
this.ownerDocument.defaultView.fetch(src)
this.ownerDocument.defaultView.fetch(src, {headers: {'user-agent': `User-Agent: ${this.ownerDocument.defaultView.navigator.userAgent}`}})
.then(res => {
if (res.status >= 200 && res.status < 300) {
return res.arrayBuffer();
Expand Down Expand Up @@ -3149,7 +3149,7 @@ class HTMLVideoElement extends HTMLMediaElement {
console.log('video downloading...');
const src = value;

this.ownerDocument.defaultView.fetch(src)
this.ownerDocument.defaultView.fetch(src, {headers: {'user-agent': `User-Agent: ${this.ownerDocument.defaultView.navigator.userAgent}`}})
.then(res => {
console.log('video download res');
if (res.status >= 200 && res.status < 300) {
Expand Down