MOBILE-3833 ws: Send User Agent in file transfer requests
parent
68708d116b
commit
e5ba19a835
|
@ -113,8 +113,11 @@ export class FileTransferObjectMock extends FileTransferObject {
|
||||||
xhr.open('GET', source, true);
|
xhr.open('GET', source, true);
|
||||||
xhr.responseType = 'blob';
|
xhr.responseType = 'blob';
|
||||||
for (const name in headers) {
|
for (const name in headers) {
|
||||||
|
// We can't set the User-Agent in browser.
|
||||||
|
if (name !== 'User-Agent') {
|
||||||
xhr.setRequestHeader(name, headers[name]);
|
xhr.setRequestHeader(name, headers[name]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xhr.onprogress = (ev: ProgressEvent): void => {
|
xhr.onprogress = (ev: ProgressEvent): void => {
|
||||||
if (this.progressListener) {
|
if (this.progressListener) {
|
||||||
|
@ -332,7 +335,7 @@ export class FileTransferObjectMock extends FileTransferObject {
|
||||||
xhr.open(httpMethod || 'POST', url);
|
xhr.open(httpMethod || 'POST', url);
|
||||||
for (const name in headers) {
|
for (const name in headers) {
|
||||||
// Filter "unsafe" headers.
|
// Filter "unsafe" headers.
|
||||||
if (name != 'Connection') {
|
if (name !=='Connection' && name !== 'User-Agent') {
|
||||||
xhr.setRequestHeader(name, headers[name]);
|
xhr.setRequestHeader(name, headers[name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,7 +270,11 @@ export class CoreWSProvider {
|
||||||
onProgress && transfer.onProgress(onProgress);
|
onProgress && transfer.onProgress(onProgress);
|
||||||
|
|
||||||
// Download the file in the tmp file.
|
// Download the file in the tmp file.
|
||||||
await transfer.download(url, fileEntry.toURL(), true);
|
await transfer.download(url, fileEntry.toURL(), true, {
|
||||||
|
headers: {
|
||||||
|
'User-Agent': navigator.userAgent, // eslint-disable-line @typescript-eslint/naming-convention
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
let extension = '';
|
let extension = '';
|
||||||
|
|
||||||
|
@ -885,7 +889,9 @@ export class CoreWSProvider {
|
||||||
itemid: options.itemId || 0,
|
itemid: options.itemId || 0,
|
||||||
};
|
};
|
||||||
options.chunkedMode = false;
|
options.chunkedMode = false;
|
||||||
options.headers = {};
|
options.headers = {
|
||||||
|
'User-Agent': navigator.userAgent, // eslint-disable-line @typescript-eslint/naming-convention
|
||||||
|
};
|
||||||
options['Connection'] = 'close';
|
options['Connection'] = 'close';
|
||||||
|
|
||||||
let success: FileUploadResult;
|
let success: FileUploadResult;
|
||||||
|
|
Loading…
Reference in New Issue