【发布时间】:2015-11-10 21:05:59
【问题描述】:
我正在尝试将内容类型设置为 $resrouce 删除操作的 application/json。我需要对 application/json 强制执行 content-type 的唯一原因是 IE10,IE11 将 DELETE 请求的 content-type 检测为纯文本/文本,但所有其他浏览器和旧版本的 IE 将其检测为 application/json .我有一个来自后端的限制,它总是检查内容类型为 Json。
这是我试图执行它的方式:
remove: {
method: 'DELETE',
headers: { 'Content-Type': 'application/json; charset=utf-8'},
transformRequest: function(data, headerGetters) {
headerGetters()['Content-Type'] = 'application/json';
return angular.toJson(data);
},
update: {
method: 'PUT'
}
但这仍然不起作用,无法将内容类型设置为 json。
【问题讨论】:
-
你在没有 transformRequest 的情况下尝试过同样的方法吗?使用 $resource 服务有限制吗?
-
我尝试不使用 transformRequest,但没有任何改变。仍然是 IE11 开发人员工具如何将内容类型作为纯文本而不是应用程序/json 传递。
标签: javascript json angularjs rest angular-resource