简体   繁体   English

AngularJS $ http删除请求Content-Type标头

[英]AngularJS $http DELETE request Content-Type header

When I make a DELETE request with AngularJS $resource module, angular adds a Content-Type: application/xml header to request headers. 当我使用AngularJS $resource模块发出DELETE请求时,angular向请求标头添加了Content-Type: application/xml标头。 In AngularJS source code , there is a section that removes content-type request header when no parameters sent. AngularJS源代码中 ,有一个部分可在未发送参数时删除内容类型请求标头。 But, I don't understand why this is happen, this doesn't works. 但是,我不明白为什么会这样,这是行不通的。

Here is how I make delete request: 这是我发出删除请求的方式:

$resource('/my/topics/:topicId').remove({ topicId: 1}, successFn, errorFn

And here is which headers browser 这是哪个标题浏览器

Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0
Content-Type:application/xml
Cookie:session=0a627145415440740d6cc8cd35d19ba3; __ngDebug=true
Host:localhost:9001
Origin:http://localhost:9001
Referer:http://localhost:9001/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36

Where that Content-Type header come from? Content-Type标头来自何处?

EDIT : I'm using AngularJS 1.2.0rc1 编辑 :我正在使用AngularJS 1.2.0rc1

I found workaround: https://github.com/angular/angular.js/issues/2149#issuecomment-22664501 我找到了解决方法: https : //github.com/angular/angular.js/issues/2149#issuecomment-22664501

I hope somebody merge this fix to angularjs master. 我希望有人将此修补程序合并到angularjs master。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM