зеркало из https://github.com/Azure/ms-rest-js.git
Fixes from feedback
This commit is contained in:
Родитель
35bd0e2b5b
Коммит
0572a2bb2e
|
@ -19,6 +19,8 @@ if (isNode) {
|
||||||
axiosClient.interceptors.request.use(config => ({ ...config, method: config.method && config.method.toUpperCase() }));
|
axiosClient.interceptors.request.use(config => ({ ...config, method: config.method && config.method.toUpperCase() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AxiosProgressFunction = (rawEvent: ProgressEvent) => void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A HttpClient implementation that uses axios to send HTTP requests.
|
* A HttpClient implementation that uses axios to send HTTP requests.
|
||||||
*/
|
*/
|
||||||
|
@ -104,10 +106,12 @@ export class AxiosHttpClient implements HttpClient {
|
||||||
httpRequest.body;
|
httpRequest.body;
|
||||||
|
|
||||||
const userUploadProgress = httpRequest.onUploadProgress;
|
const userUploadProgress = httpRequest.onUploadProgress;
|
||||||
const onUploadProgress = userUploadProgress && ((rawEvent: ProgressEvent) => userUploadProgress({ loaded: rawEvent.loaded, total: rawEvent.lengthComputable ? rawEvent.total : undefined }));
|
const onUploadProgress: AxiosProgressFunction | undefined = userUploadProgress && (rawEvent =>
|
||||||
|
userUploadProgress({ loadedBytes: rawEvent.loaded, totalBytes: rawEvent.lengthComputable ? rawEvent.total : undefined }));
|
||||||
|
|
||||||
const userDownloadProgress = httpRequest.onDownloadProgress;
|
const userDownloadProgress = httpRequest.onDownloadProgress;
|
||||||
const onDownloadProgress = userDownloadProgress && ((rawEvent: ProgressEvent) => userDownloadProgress({ loaded: rawEvent.loaded, total: rawEvent.lengthComputable ? rawEvent.total : undefined }));
|
const onDownloadProgress: AxiosProgressFunction | undefined = userDownloadProgress && (rawEvent =>
|
||||||
|
userDownloadProgress({ loadedBytes: rawEvent.loaded, totalBytes: rawEvent.lengthComputable ? rawEvent.total : undefined }));
|
||||||
|
|
||||||
let res: AxiosResponse;
|
let res: AxiosResponse;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -16,13 +16,13 @@ export type TransferProgressEvent = {
|
||||||
/**
|
/**
|
||||||
* The number of bytes loaded so far.
|
* The number of bytes loaded so far.
|
||||||
*/
|
*/
|
||||||
loaded: number,
|
loadedBytes: number,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The total number of bytes that will be loaded.
|
* The total number of bytes that will be loaded.
|
||||||
* If the total number of bytes is unknown, this property will be undefined.
|
* If the total number of bytes is unknown, this property will be undefined.
|
||||||
*/
|
*/
|
||||||
total?: number
|
totalBytes?: number
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -180,12 +180,12 @@ describe("axiosHttpClient", () => {
|
||||||
ev => {
|
ev => {
|
||||||
uploadNotified = true;
|
uploadNotified = true;
|
||||||
ev.should.not.be.instanceof(ProgressEvent);
|
ev.should.not.be.instanceof(ProgressEvent);
|
||||||
ev.loaded.should.be.a.Number;
|
ev.loadedBytes.should.be.a.Number;
|
||||||
},
|
},
|
||||||
ev => {
|
ev => {
|
||||||
downloadNotified = true;
|
downloadNotified = true;
|
||||||
ev.should.not.be.instanceof(ProgressEvent);
|
ev.should.not.be.instanceof(ProgressEvent);
|
||||||
ev.loaded.should.be.a.Number;
|
ev.loadedBytes.should.be.a.Number;
|
||||||
});
|
});
|
||||||
|
|
||||||
const client = new AxiosHttpClient();
|
const client = new AxiosHttpClient();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче