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

Commit ca22db9

Browse files
committed
feat($http): upload and download event
1 parent 301e7aa commit ca22db9

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Diff for: src/ng/http.js

100644100755
+8-1
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,13 @@ function $HttpProvider() {
750750
</example>
751751
*/
752752
function $http(requestConfig) {
753+
var config = {
754+
method: 'get',
755+
transformRequest: defaults.transformRequest,
756+
transformResponse: defaults.transformResponse,
757+
progress: null
758+
};
759+
var headers = mergeHeaders(requestConfig);
753760

754761
if (!angular.isObject(requestConfig)) {
755762
throw minErr('$http')('badreq', 'Http request configuration must be an object. Received: {0}', requestConfig);
@@ -1067,7 +1074,7 @@ function $HttpProvider() {
10671074
}
10681075

10691076
$httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout,
1070-
config.withCredentials, config.responseType);
1077+
config.withCredentials, config.responseType, config.progress);
10711078
}
10721079

10731080
return promise;

Diff for: 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)