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

Commit 37d245b

Browse files
committed
feat($http): upload and download event
1 parent 6046e14 commit 37d245b

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
@@ -683,7 +683,8 @@ function $HttpProvider() {
683683
var config = {
684684
method: 'get',
685685
transformRequest: defaults.transformRequest,
686-
transformResponse: defaults.transformResponse
686+
transformResponse: defaults.transformResponse,
687+
progress: null
687688
};
688689
var headers = mergeHeaders(requestConfig);
689690

@@ -990,7 +991,7 @@ function $HttpProvider() {
990991
}
991992

992993
$httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout,
993-
config.withCredentials, config.responseType);
994+
config.withCredentials, config.responseType, config.progress);
994995
}
995996

996997
return promise;

src/ng/httpBackend.js

100644100755
+8-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
4040
var ABORTED = -1;
4141

4242
// TODO(vojta): fix the signature
43-
return function(method, url, post, callback, headers, timeout, withCredentials, responseType) {
43+
return function(method, url, post, callback, headers, timeout, withCredentials, responseType, progressCallback) {
4444
var status;
4545
$browser.$$incOutstandingRequestCount();
4646
url = url || $browser.url();
@@ -68,6 +68,13 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
6868
}
6969
});
7070

71+
if (typeof progressCallback === "function") {
72+
xhr.onprogress = progressCallback;
73+
if ("upload" in xhr) {
74+
xhr.upload.onprogress = progressCallback;
75+
}
76+
}
77+
7178
// In IE6 and 7, this might be called synchronously when xhr.send below is called and the
7279
// response is in the cache. the promise api will ensure that to the app code the api is
7380
// always async

0 commit comments

Comments
 (0)