mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-11 00:03:10 +00:00
Normalize IE XHR bug (status code 1223 to 204)
See http://bugs.jquery.com/ticket/1450
This commit is contained in:
parent
805e083c24
commit
b2f5299e0e
2 changed files with 16 additions and 1 deletions
|
|
@ -113,7 +113,9 @@ function Browser(window, document, body, XHR, $log) {
|
||||||
});
|
});
|
||||||
xhr.onreadystatechange = function() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState == 4) {
|
if (xhr.readyState == 4) {
|
||||||
completeOutstandingRequest(callback, xhr.status || 200, xhr.responseText);
|
// normalize IE bug (http://bugs.jquery.com/ticket/1450)
|
||||||
|
var status = xhr.status == 1223 ? 204 : xhr.status || 200;
|
||||||
|
completeOutstandingRequest(callback, status, xhr.responseText);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.send(post || '');
|
xhr.send(post || '');
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,19 @@ describe('browser', function(){
|
||||||
expect(response).toEqual('RESPONSE');
|
expect(response).toEqual('RESPONSE');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should normalize IE\'s 1223 status code into 204', function() {
|
||||||
|
var callback = jasmine.createSpy('XHR');
|
||||||
|
|
||||||
|
browser.xhr('GET', 'URL', 'POST', callback);
|
||||||
|
|
||||||
|
xhr.status = 1223;
|
||||||
|
xhr.readyState = 4;
|
||||||
|
xhr.onreadystatechange();
|
||||||
|
|
||||||
|
expect(callback).toHaveBeenCalled();
|
||||||
|
expect(callback.argsForCall[0][0]).toEqual(204);
|
||||||
|
});
|
||||||
|
|
||||||
it('should not set Content-type header for GET requests', function() {
|
it('should not set Content-type header for GET requests', function() {
|
||||||
browser.xhr('GET', 'URL', 'POST-DATA', function(c, r) {});
|
browser.xhr('GET', 'URL', 'POST-DATA', function(c, r) {});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue