gpt4 book ai didi

angularjs - 使用 angularjs $http 将内容类型设置为 utf-8

转载 作者:行者123 更新时间:2023-12-04 23:52:37 25 4
gpt4 key购买 nike

我正在将包含文件、文本等的表单上传到 appengine blobstore:

$http({
method: 'POST',
url: the_url,
transformRequest: formDataObject,
data: event,
headers: {'Content-Type': undefined}
})

请求使用以下 header 成功发送:
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryYeRxOO7y3qHNWd83

当我尝试将内容类型设置为 "multipart/form-data;charset=UTF-8" 时我失去了边界并在响应中收到错误: Bad content type. Please use multipart.
添加 UTF-8 字符集的正确方法是什么?

最佳答案

根据 RFC 1341:
As stated in the definition of the Content-Transfer-Encoding field, no encoding other than "7bit", "8bit", or "binary" is permitted for entities of type "multipart". The multipart delimiters and header fields are always 7-bit ASCII in any case, and data within the body parts can be encoded on a part-by-part basis, with Content-Transfer-Encoding fields for each appropriate body part.
所以你必须使用 Content-Transfer-Encoding而不是 Content-Type在这种情况下。

关于angularjs - 使用 angularjs $http 将内容类型设置为 utf-8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20461594/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com