设置内容类型为UTF-8 angularjs $ HTTP [英] set content-type to utf-8 with angularjs $http
问题描述
我上传与文件的形式,文字等的AppEngine上Blob存储区:
I'm uploading a form with files, text etc to the appengine blobstore:
$http({
method: 'POST',
url: the_url,
transformRequest: formDataObject,
data: event,
headers: {'Content-Type': undefined}
})
请求与follwing头发送成功:
The request sends successfully with the follwing header:
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryYeRxOO7y3qHNWd83
当我尝试的内容类型设置为的multipart / form-data的;字符集= UTF-8
我失去了边界并获得响应的错误: 坏的内容类型。请使用多部分。
When I try setting the content-type to "multipart/form-data;charset=UTF-8"
I lose the boundary and get an error in the response: Bad content type. Please use multipart.
什么是添加UTF-8字符集的正确方法是什么?
What is the correct way to add the UTF-8 charset?
推荐答案
根据RFC 1341:
According to RFC 1341:
正如在内容传送编码字段的定义指出,没有比7位等编码,8位,或者二进制是允许的类型多部分的实体。多部分分隔符和报头字段总是在任何情况下,7位ASCII,以及身体各部位中的数据可以连接codeD上的一部分,由部分的基础上,对每个相应的身体部位的Content-Transfer-Encoding的领域
所以,你必须使用内容传输编码
而不是内容类型
在这种情况下。
So you have to use Content-Transfer-Encoding
instead of Content-Type
in this case.
这篇关于设置内容类型为UTF-8 angularjs $ HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!