aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorg2014-01-08 11:23:33 +1000
committerIgor Minar2014-01-31 16:52:42 -0800
commitef210e5e119db4f5bfc9d2428b19f9b335c4f976 (patch)
tree8ad111f18ed6ce9f601afec45c53ac87b221a715
parentfd61e222c337380af09ff08dc3fe73f17e9a7a8e (diff)
downloadangular.js-ef210e5e119db4f5bfc9d2428b19f9b335c4f976.tar.bz2
fix($http): update httpBackend to use ActiveXObject on IE8 if necessary
window.XMLHttpRequest is not always available in IE8 despite it not running in quirks mode, in which case Angular should be using the ActiveXObject instead. Just checking the browser version is taking too many shortcuts. Closes #5677 Closes #5679
-rw-r--r--docs/content/error/httpBackend/noxhr.ngdoc10
-rw-r--r--src/ng/httpBackend.js17
2 files changed, 21 insertions, 6 deletions
diff --git a/docs/content/error/httpBackend/noxhr.ngdoc b/docs/content/error/httpBackend/noxhr.ngdoc
new file mode 100644
index 00000000..e2d5901d
--- /dev/null
+++ b/docs/content/error/httpBackend/noxhr.ngdoc
@@ -0,0 +1,10 @@
+@ngdoc error
+@name $httpBackend:noxhr
+@fullName Unsupported XHR
+@description
+
+This error occurs in browsers that do not support XmlHttpRequest. AngularJS
+supports Safari, Chrome, Firefox, Opera, IE8 and higher, and mobile browsers
+(Android, Chrome Mobile, iOS Safari). To avoid this error, use an officially
+supported browser.
+
diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js
index f52e4611..665c5eec 100644
--- a/src/ng/httpBackend.js
+++ b/src/ng/httpBackend.js
@@ -1,13 +1,18 @@
'use strict';
function createXhr(method) {
- // IE8 doesn't support PATCH method, but the ActiveX object does
- /* global ActiveXObject */
- return (msie <= 8 && lowercase(method) === 'patch')
- ? new ActiveXObject('Microsoft.XMLHTTP')
- : new window.XMLHttpRequest();
-}
+ //if IE and the method is not RFC2616 compliant, or if XMLHttpRequest
+ //is not available, try getting an ActiveXObject. Otherwise, use XMLHttpRequest
+ //if it is available
+ if (msie <= 8 && (!method.match(/^(get|post|head|put|delete|options)$/i) ||
+ !window.XMLHttpRequest)) {
+ return new ActiveXObject("Microsoft.XMLHTTP");
+ } else if (window.XMLHttpRequest) {
+ return new window.XMLHttpRequest();
+ }
+ throw minErr('$httpBackend')('noxhr', "This browser does not support XMLHttpRequest.");
+}
/**
* @ngdoc object