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

Commit e3c820e

Browse files
committed
feat($http): upload and download event
1 parent 048a5f1 commit e3c820e

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
@@ -619,7 +619,8 @@ function $HttpProvider() {
619619
var config = {
620620
method: 'get',
621621
transformRequest: defaults.transformRequest,
622-
transformResponse: defaults.transformResponse
622+
transformResponse: defaults.transformResponse,
623+
progress: null
623624
};
624625
var headers = mergeHeaders(requestConfig);
625626

@@ -925,7 +926,7 @@ function $HttpProvider() {
925926
}
926927

927928
$httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout,
928-
config.withCredentials, config.responseType);
929+
config.withCredentials, config.responseType, config.progress);
929930
}
930931

931932
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)