Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 发出http请求时删除内容类型标头_Angularjs_Http_Http Headers - Fatal编程技术网

Angularjs 发出http请求时删除内容类型标头

Angularjs 发出http请求时删除内容类型标头,angularjs,http,http-headers,Angularjs,Http,Http Headers,我一直试图上传表单数据,但我不想发送任何内容类型的标题。我试过了 headers: { 'X-Content-Type-Options': 'nosniff', 'Content-Type': undefined } 但是请求仍然包含 Content-Type:multipart/form-data; boundary=----WebKitFormBoundarykplXRCRn92v5Op52 参考代码块: $http({

我一直试图上传表单数据,但我不想发送任何内容类型的标题。我试过了

headers: {
           'X-Content-Type-Options': 'nosniff',
           'Content-Type': undefined
         }
但是请求仍然包含

Content-Type:multipart/form-data; boundary=----WebKitFormBoundarykplXRCRn92v5Op52
参考代码块:

$http({
    url: "/file/",
    method: 'POST',
    data: {
        'file': res
    },
    headers: {
        'Content-Type': undefined
    }
})
我无法理解到底发生了什么。任何帮助都将不胜感激

PS:我理解什么是多部分表单数据。我只需要去掉标题。

检查以下答案:


在我看来,这些答案解决了你的问题。如果没有,请粘贴准备请求的代码。

如果使用
“Content-Type”:“application/json;字符集=UTF-8'
'Content-Type':'text/plain;字符集=UTF-8'
?AngularJS默认内容类型为application/json;当我将内容类型设置为
undefined
时,我的浏览器(Chrome)会插入
内容类型:text/plain;charset=UTF-8
@georgeawg我尝试将其设置为“application/json”,但由于我正在发送多部分表单数据,它会以某种方式更改标题。我怀疑它是否是由浏览器完成的。