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

$http.delete causes non-zero Content-Length header in IE10 due to passing undefined to xhr.send #12141

Closed
zps938 opened this issue Jun 17, 2015 · 3 comments

Comments

@zps938
Copy link

zps938 commented Jun 17, 2015

Since 1.4.0-rc1 and confirmed in 1.4.1, calling $http.delete('url') in IE10 causes a non-zero Content-Length header to be added to the request. I noticed this when the webserver was returning HTTP error code 415 on all $http.delete calls.

I tracked this down to 1.4.0-rc1 where xhr.send(post || null) in createHttpBackend was changed to xhr.send(post). When post is undefined, this problem occurs in IE10. The code below reproduces this bug in IE10 and is essentially what $http.delete('url') is doing.

var xhr= new window.XMLHttpRequest();
var post;
xhr.open('DELETE', 'url', true);
xhr.send(post);

Changing xhr.send(post) to xhr.send(post || null) fixes the problem.

@pkozlowski-opensource
Copy link
Member

This was changed in e04a887 (which looks like a valid fix). I guess we need to find another work-around for IE (probably be explicitly passing null for the requests without body)

@mstock
Copy link

mstock commented Aug 4, 2015

This issue seems to affect AngularJS 1.4.3 on IE11 as well. I was able to work around it by passing { data: null } as second parameter to the delete() method of the $http service.

@zps938
Copy link
Author

zps938 commented Aug 4, 2015

This defect also affects POSTs with no data.

@Narretz Narretz modified the milestones: 1.4.4, 1.4.5 Aug 14, 2015
@Narretz Narretz modified the milestones: 1.4.5, 1.4.6 Aug 31, 2015
gkalpak added a commit to gkalpak/angular.js that referenced this issue Sep 3, 2015
IE11 (and maybe others) converts an `undefined` argument to `xhr.send()` to
string (`'undefined'`) for certain request methods (e.g. DELETE). This
causes the request to appear having a body, when it shouldn't.

Fixes angular#12141
Fixes angular#12739
@gkalpak gkalpak closed this as completed in 6f39f10 Sep 3, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants