提交 963f4940 编写于 作者: d-u-a's avatar d-u-a

fix: request Content-Type=application/x-www-form-urlencoded 数据格式不正确问题

上级 88419790
......@@ -30,6 +30,16 @@ export function createRequestTaskById (requestTaskId, {
if (!hasContentType && name.toLowerCase() === 'content-type') {
hasContentType = true
headers['Content-Type'] = header[name]
// TODO 需要重构
if(method === 'POST' && header[name].indexOf('application/x-www-form-urlencoded') === 0) {
let bodyArray = []
for (let key in data) {
if (data.hasOwnProperty(key)) {
bodyArray.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]))
}
}
data = bodyArray.join('&')
}
} else {
headers[name] = header[name]
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册