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

stop coercing falsy values to null before xhr.send() #11582

Closed
wants to merge 3 commits 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
7 changes: 6 additions & 1 deletion src/ng/httpBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDoc
}
}

xhr.send(post || null);
if (post === false) {
xhr.send(post);
}
else {
xhr.send(post || null);
}
}

if (timeout > 0) {
Expand Down
7 changes: 7 additions & 0 deletions test/ng/httpBackendSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ describe('$httpBackend', function() {
expect(xhr.$$data).toBe(null);
});

it('should pass false to send if false body is set', function() {
$backend('GET', '/some-url', false, noop);
xhr = MockXhr.$$lastInstance;

expect(xhr.$$data).toBe(false);
});

it('should call completion function with xhr.statusText if present', function() {
callback.andCallFake(function(status, response, headers, statusText) {
expect(statusText).toBe('OK');
Expand Down