mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-05 17:01:19 +08:00
fix($http): don't covert 0 status codes to 404 for non-file protocols
PR #5547 introduced conversion of all 0 status codes to 404 for cases where no response was recieved (previously this was done for the file:// protocol only). But this mechanism is too eager and masks legitimate cases where status 0 should be returned. This commits reverts to the previous mechanism of handling 0 status code for the file:// protocol (converting 0 to 404) while retaining the returned status code 0 for all the protocols other than file:// Fixes #6074 Fixes #6155
This commit is contained in:
committed by
Vojta Jina
parent
bfb6af7053
commit
56e73ea355
@@ -456,7 +456,17 @@ describe('$httpBackend', function() {
|
||||
}
|
||||
|
||||
|
||||
it('should convert 0 to 200 if content', function() {
|
||||
it('should convert 0 to 200 if content and file protocol', function() {
|
||||
$backend = createHttpBackend($browser, createMockXhr);
|
||||
|
||||
$backend('GET', 'file:///whatever/index.html', null, callback);
|
||||
respond(0, 'SOME CONTENT');
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
expect(callback.mostRecentCall.args[0]).toBe(200);
|
||||
});
|
||||
|
||||
it('should convert 0 to 200 if content for protocols other than file', function() {
|
||||
$backend = createHttpBackend($browser, createMockXhr);
|
||||
|
||||
$backend('GET', 'someProtocol:///whatever/index.html', null, callback);
|
||||
@@ -466,17 +476,25 @@ describe('$httpBackend', function() {
|
||||
expect(callback.mostRecentCall.args[0]).toBe(200);
|
||||
});
|
||||
|
||||
|
||||
it('should convert 0 to 404 if no content', function() {
|
||||
it('should convert 0 to 404 if no content and file protocol', function() {
|
||||
$backend = createHttpBackend($browser, createMockXhr);
|
||||
|
||||
$backend('GET', 'someProtocol:///whatever/index.html', null, callback);
|
||||
$backend('GET', 'file:///whatever/index.html', null, callback);
|
||||
respond(0, '');
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
expect(callback.mostRecentCall.args[0]).toBe(404);
|
||||
});
|
||||
|
||||
it('should not convert 0 to 404 if no content for protocols other than file', function() {
|
||||
$backend = createHttpBackend($browser, createMockXhr);
|
||||
|
||||
$backend('GET', 'someProtocol:///whatever/index.html', null, callback);
|
||||
respond(0, '');
|
||||
|
||||
expect(callback).toHaveBeenCalled();
|
||||
expect(callback.mostRecentCall.args[0]).toBe(0);
|
||||
});
|
||||
|
||||
it('should convert 0 to 404 if no content - relative url', function() {
|
||||
var originalUrlParsingNode = urlParsingNode;
|
||||
@@ -486,10 +504,10 @@ describe('$httpBackend', function() {
|
||||
hash : "#/C:/",
|
||||
host : "",
|
||||
hostname : "",
|
||||
href : "someProtocol:///C:/base#!/C:/foo",
|
||||
href : "file:///C:/base#!/C:/foo",
|
||||
pathname : "/C:/foo",
|
||||
port : "",
|
||||
protocol : "someProtocol:",
|
||||
protocol : "file:",
|
||||
search : "",
|
||||
setAttribute: angular.noop
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user