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