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

fix(angular.js): wrong $httpBackend status code #4514

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/httpBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
jsonpDone = xhr = null;

// fix status code for file protocol (it's always 0)
status = (protocol == 'file') ? (response ? 200 : 404) : status;
status = (protocol == 'file' && status === 0) ? (response ? 200 : 404) : status;

// normalize IE bug (http://bugs.jquery.com/ticket/1450)
status = status == 1223 ? 204 : status;
Expand Down
10 changes: 10 additions & 0 deletions test/ng/httpBackendSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,16 @@ describe('$httpBackend', function() {
expect(callback).toHaveBeenCalled();
expect(callback.mostRecentCall.args[0]).toBe(404);
});

it('should return backend status code', function () {
$backend = createHttpBackend($browser, MockXhr, null, null, null, 'file');

$backend('POST', 'http://rest_api/create_whatever', null, callback);
respond(201, '');

expect(callback).toHaveBeenCalled();
expect(callback.mostRecentCall.args[0]).toBe(201);
});
});
});