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

Commit 24699ee

Browse files
committed
fix($http): ignore xhr.responseType setter exception if value is "json"
WebKit added support for the json responseType value on 09/03/2013 https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are known to throw when setting the value "json" as the response type. Other older browsers implementing the responseType. Other browsers with infrequent update cycles may also be affected. The json responseType value can be ignored if not supported, because JSON payloads are parsed on the client-side regardless. Closes #6115 Closes #6122
1 parent aa6a0e3 commit 24699ee

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/ng/httpBackend.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,20 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
107107
}
108108

109109
if (responseType) {
110-
xhr.responseType = responseType;
110+
try {
111+
xhr.responseType = responseType;
112+
} catch (e) {
113+
// WebKit added support for the json responseType value on 09/03/2013
114+
// https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are
115+
// known to throw when setting the value "json" as the response type. Other older
116+
// browsers implementing the responseType
117+
//
118+
// The json response type can be ignored if not supported, because JSON payloads are
119+
// parsed on the client-side regardless.
120+
if (responseType !== 'json') {
121+
throw e;
122+
}
123+
}
111124
}
112125

113126
xhr.send(post || null);

0 commit comments

Comments
 (0)