From ff1deb7e802a19c84ca26ba7a9b0713fe0c47809 Mon Sep 17 00:00:00 2001 From: Darren-supreme Date: Sat, 20 Mar 2021 00:54:23 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8Dcontent-type=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=80=BC=E5=AF=BC=E8=87=B4=E6=8F=90=E4=BA=A4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B9=B1=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fly.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fly.js b/src/fly.js index ce11d92..5497e19 100644 --- a/src/fly.js +++ b/src/fly.js @@ -186,11 +186,13 @@ class Fly { let customContentType = options.headers[contentType] || options.headers[contentTypeLowerCase]; // default content type + let defaultContentType = ["application/x-www-form-urlencoded","application/x-www-form-urlencoded;charset=utf-8"]; let _contentType = "application/x-www-form-urlencoded"; // If the request data is json object, transforming it to json string, // and set request content-type to "json". In browser, the data will // be sent as RequestBody instead of FormData - if (utils.trim((customContentType || "").toLowerCase()) === _contentType) { + if (defaultContentType.indexOf(utils.trim((customContentType || "").toLowerCase())) !== -1) { + _contentType = utils.trim((customContentType || "").toLowerCase()); data = utils.formatParams(data); } else if (!utils.isFormData(data) && ["object", "array"].indexOf(utils.type(data)) !== -1) { _contentType = 'application/json;charset=utf-8'