-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Unable to set content-type request header for delete method. #2149
Comments
Having similar issues with put and post. Content-Type of the request is always set as application/xml |
I am having the exact same issue. Impossible to change the Content-Type of a DELETE request. |
I think if there is no request body ( Line 638 in b99d064
The code above worked for me when the data parameter is set. |
Running into the same issue as well. When working with a framework that expects content-type for all HTTP verbs, this is an issue. Also, since neither GET and DELETE support content, I would expect them both to work the same way. |
I wonder if there is a specific reason the content-type is stripped? JQuery doesn't make that assumption for example. This was a frustrating little feature to find out. |
Is DELETE supposed to have When using $http.delete(url) we've been seeing the following: Chrome 28 (and some lower):
FireFox 22: IE 10: The
We didn't have this issue and no 'Content-Type' was specified.
The issue seems to be with this piece of code in $httpBackend:
If you simply change that to something like:
Then all is well with the world. I've tested it on the 1.1.5 tag and all the tests pass in Mac Chrome/Safari include e2e, but I haven't a clue how to write tests for it or I'd submit a pull request. Currently we are forced to run a modifed version of angular, but we'd like to run the google cdn version. Any suggestions? |
👍 |
2 similar comments
+1 |
+1 |
works too. I hope somebody merges this fix to master. |
👍 |
1 similar comment
+1 |
OK. It's been 5 months now. It would be nice to get some kind of feedback from one of the core committers. |
My pull request about this issue has been included in milestone 1.2.0-rc3: #3897 I hope, it will be merged in next release. |
Excellent! |
Just ran into this issue with 1.0.8; hope the fix will be included in a 1.0.9 release! Until then, it appears that AngularJS won't work with the current version of the popular Play framework (2.2)... |
@ejain Yes it does, just add |
@mariussoutier Thanks for the workaround; unfortunately there does not appear to be an equivalent of |
PR that tests and fixes this: |
The XMLHttpRequest.send spec defines different semantics for `null` than for an empty String: an empty String should be sent with a `Content-Type` of `text/plain`, whereas null should have no `Content-Type` header set. Closes angular#2149
one question about the changes concerning xhr.send(post || null); and forEach(headers, function(value, key) {
if (isDefined(value)) {
xhr.setRequestHeader(key, value);
}
}); That makes problems when an empty POST request is made in an CORS enabled environment. Because CORS will interpret the Content-Type header and with that changes there is absolutely no way to define an Content-Type header for an empty POST. Problem reproduced with angular 1.2.9 |
The `XMLHttpRequest.send` spec defines different semantics for `null` than for an empty String: an empty String should be sent with a `Content-Type` of `text/plain`, whereas `null` should have no `Content-Type` header set. Closes angular#2149
The `XMLHttpRequest.send` spec defines different semantics for `null` than for an empty String: an empty String should be sent with a `Content-Type` of `text/plain`, whereas `null` should have no `Content-Type` header set. Closes angular#2149
Still can not set content type with $resource on GET (empty POST have not check yet). =\ |
I just migrated from 1.2 to 1.4. It seems the issue is back. Default Content-type set to text/* for Delete request. |
|
+1 |
+1 |
If you are still experiencing buggy behaviour, I suggest opening a new issue (providing the necessary info - preferrably along with a live demo, using CodePen, Plnkr etc). It's hard to interpret +1s on an issue that (is supposed to) have been fixed. |
I'm having the same issue, tried to reproduce it in a Plunk (v1.4.8), but no success, and locally (also v1.4.8), i'm facing it, don't know if it makes any difference, but my request is to a rest application in a local hosted VirtualBox VM. Punkler Request info:
My local Request info:
I'm using the same method locally, a lot Headers are different, i don't know why. |
@vniche: This seems to be a different issue (and one not related to Angular). In any case, this is not something caused or affected by Angular. |
I tried as below approach-
$httpProvider.defaults.headers["delete"] = {'Content-Type': 'application/json;charset=utf-8'};
My request doesn't have any body. And the actual request header is always taking "content-type" as "text/plain".
The text was updated successfully, but these errors were encountered: