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

$httpBackend coersion of falsy values to null before xhr.send() #11552

Closed
johnhoffman opened this issue Apr 13, 2015 · 4 comments
Closed

$httpBackend coersion of falsy values to null before xhr.send() #11552

johnhoffman opened this issue Apr 13, 2015 · 4 comments

Comments

@johnhoffman
Copy link
Contributor

Can anyone explain why this line in $httpBackend should coerce falsy values to null?

xhr.send(post || null);

https://github.com/angular/angular.js/blob/master/src/ng/httpBackend.js#L112

This means that, if I need to POST, PUT, etc. an actual boolean false to a web service, I have to work around AngularJS.

I'd like the line to read something like this:

xhr.send(post);

or if it just can't be undefined or something:

xhr.send(isDefined(post) ? post : null);
@johnhoffman johnhoffman changed the title $httpBackend coersion of falsey values to null before xhr.send() $httpBackend coersion of falsy values to null before xhr.send() Apr 13, 2015
@pkozlowski-opensource
Copy link
Member

@johnhoffman I think that your analysis is correct, we are too eager with falsy checks here. Would you be up to sending us a PR. The line to be modified is this one

@johnhoffman
Copy link
Contributor Author

I've initiated PR #11567. I had trouble resolving an recurring error while attempting to run the tests on my local machine (Error: Cannot find module 'es6-symbol'), so I'm not sure if it will pass the Travis CI check.

@johnhoffman
Copy link
Contributor Author

I've closed #11567 initiated a new PR #11582 to get the Travis CI tests to run again (sorry if there was a better way to do this).

@johnhoffman
Copy link
Contributor Author

Last try before trying to dig into what the test results are saying... PR #11593

johnhoffman added a commit to johnhoffman/angular.js that referenced this issue Apr 16, 2015
@caitp caitp closed this as completed in e04a887 Apr 17, 2015
netman92 pushed a commit to netman92/angular.js that referenced this issue Aug 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.