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

Commit b2f5299

Browse files
committed
Normalize IE XHR bug (status code 1223 to 204)
See http://bugs.jquery.com/ticket/1450
1 parent 805e083 commit b2f5299

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Browser.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ function Browser(window, document, body, XHR, $log) {
113113
});
114114
xhr.onreadystatechange = function() {
115115
if (xhr.readyState == 4) {
116-
completeOutstandingRequest(callback, xhr.status || 200, xhr.responseText);
116+
// normalize IE bug (http://bugs.jquery.com/ticket/1450)
117+
var status = xhr.status == 1223 ? 204 : xhr.status || 200;
118+
completeOutstandingRequest(callback, status, xhr.responseText);
117119
}
118120
};
119121
xhr.send(post || '');

test/BrowserSpecs.js

+13
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ describe('browser', function(){
124124
expect(response).toEqual('RESPONSE');
125125
});
126126

127+
it('should normalize IE\'s 1223 status code into 204', function() {
128+
var callback = jasmine.createSpy('XHR');
129+
130+
browser.xhr('GET', 'URL', 'POST', callback);
131+
132+
xhr.status = 1223;
133+
xhr.readyState = 4;
134+
xhr.onreadystatechange();
135+
136+
expect(callback).toHaveBeenCalled();
137+
expect(callback.argsForCall[0][0]).toEqual(204);
138+
});
139+
127140
it('should not set Content-type header for GET requests', function() {
128141
browser.xhr('GET', 'URL', 'POST-DATA', function(c, r) {});
129142

0 commit comments

Comments
 (0)