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

Commit 3acad64

Browse files
committed
refactor($http) Simplify code by removing the createXhr() method
This removes a workaround for IE 8 and and error handling for IE6.
1 parent a8fe2cc commit 3acad64

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/ng/httpBackend.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
'use strict';
22

3-
function createXhr(method) {
4-
//if IE and the method is not RFC2616 compliant, or if XMLHttpRequest
5-
//is not available, try getting an ActiveXObject. Otherwise, use XMLHttpRequest
6-
//if it is available
7-
if (msie <= 8 && (!method.match(/^(get|post|head|put|delete|options)$/i) ||
8-
!window.XMLHttpRequest)) {
9-
return new window.ActiveXObject("Microsoft.XMLHTTP");
10-
} else if (window.XMLHttpRequest) {
11-
return new window.XMLHttpRequest();
12-
}
13-
14-
throw minErr('$httpBackend')('noxhr', "This browser does not support XMLHttpRequest.");
15-
}
16-
173
/**
184
* @ngdoc service
195
* @name $httpBackend
@@ -32,11 +18,11 @@ function createXhr(method) {
3218
*/
3319
function $HttpBackendProvider() {
3420
this.$get = ['$browser', '$window', '$document', function($browser, $window, $document) {
35-
return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]);
21+
return createHttpBackend($browser, $browser.defer, $window.angular.callbacks, $document[0]);
3622
}];
3723
}
3824

39-
function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) {
25+
function createHttpBackend($browser, $browserDefer, callbacks, rawDocument) {
4026
var ABORTED = -1;
4127

4228
// TODO(vojta): fix the signature
@@ -59,7 +45,7 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
5945
});
6046
} else {
6147

62-
var xhr = createXhr(method);
48+
var xhr = new window.XMLHttpRequest();
6349

6450
xhr.open(method, url, true);
6551
forEach(headers, function(value, key) {

0 commit comments

Comments
 (0)