发出http请求时删除内容类型标头 [英] Remove Content type header when making an http request

查看:105
本文介绍了发出http请求时删除内容类型标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试上传表单数据,但是我不想发送任何Content-Type标头.我尝试设置

I have been trying to upload form-data, but I do not want to send any Content-Type header. I have tried setting

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
    }
})

我无法理解到底发生了什么.任何帮助将不胜感激.

I am unable to understand what exactly is happening. Any help would be greatly appreciated.

PS:我了解什么是多部分形式的数据.我只需要剥离该标头即可.

PS: I understand what is multipart-form data. I just need to strip off that header.

推荐答案

检查以下答案:

enctype ='multipart/form-data'是什么意思?

>是否始终需要Content-Type HTTP标头?

我认为这些答案可以解决您的问题.如果没有,请粘贴准备您的请求的代码.

In my opinion these answers solves your problem. If not, paste code that prepares your request.

这篇关于发出http请求时删除内容类型标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆