Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 1e7a8b7

Browse files
committed
feat($http): upload and download event
1 parent 1e6a5b2 commit 1e7a8b7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/ng/http.js

100644100755
+3-2
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,8 @@ function $HttpProvider() {
739739
var config = {
740740
method: 'get',
741741
transformRequest: defaults.transformRequest,
742-
transformResponse: defaults.transformResponse
742+
transformResponse: defaults.transformResponse,
743+
progress: null
743744
};
744745
var headers = mergeHeaders(requestConfig);
745746

@@ -1053,7 +1054,7 @@ function $HttpProvider() {
10531054
}
10541055

10551056
$httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout,
1056-
config.withCredentials, config.responseType);
1057+
config.withCredentials, config.responseType, config.progress);
10571058
}
10581059

10591060
return promise;

src/ng/httpBackend.js

100644100755
+8-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function $HttpBackendProvider() {
2828

2929
function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) {
3030
// TODO(vojta): fix the signature
31-
return function(method, url, post, callback, headers, timeout, withCredentials, responseType) {
31+
return function(method, url, post, callback, headers, timeout, withCredentials, responseType, progressCallback) {
3232
$browser.$$incOutstandingRequestCount();
3333
url = url || $browser.url();
3434

@@ -109,6 +109,13 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
109109
}
110110
}
111111

112+
if (typeof progressCallback === "function") {
113+
xhr.onprogress = progressCallback;
114+
if ("upload" in xhr) {
115+
xhr.upload.onprogress = progressCallback;
116+
}
117+
}
118+
112119
xhr.send(post || null);
113120
}
114121

0 commit comments

Comments
 (0)