From 7cf5f385f4e68e68c6fae9f847bdd36aca73e213 Mon Sep 17 00:00:00 2001 From: cmstar Date: Mon, 5 Jun 2023 16:08:50 +0800 Subject: [PATCH] =?UTF-8?q?bug=20fix=EF=BC=9A=E4=BD=BF=E7=94=A8=20Content-?= =?UTF-8?q?Type:=20multipart/form-data=20=E6=A0=BC=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=97=B6=EF=BC=8C=20body=20=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=9A=84=E5=8F=82=E6=95=B0=E4=B8=8D=E8=83=BD=E8=A2=AB?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E8=A7=A3=E6=9E=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- slimapi/slimapi_name_resolver.go | 3 +++ slimapi/slimapi_name_resolver_test.go | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/slimapi/slimapi_name_resolver.go b/slimapi/slimapi_name_resolver.go index f17d0fa..d0814b2 100644 --- a/slimapi/slimapi_name_resolver.go +++ b/slimapi/slimapi_name_resolver.go @@ -72,6 +72,9 @@ func (d *slimApiNameResolver) FillMethod(state *webapi.ApiState) { case webapi.ContentTypeForm: requestFormat = meta_RequestFormat_Post + + case webapi.ContentTypeMultipartForm: + requestFormat = meta_RequestFormat_Post } } else { // 指定的 format 串还可包含多段使用逗号隔开的值( e.g. json,plain ), plain 是对应回执的,需单独处理。 diff --git a/slimapi/slimapi_name_resolver_test.go b/slimapi/slimapi_name_resolver_test.go index 05bfb8e..12b7e9d 100644 --- a/slimapi/slimapi_name_resolver_test.go +++ b/slimapi/slimapi_name_resolver_test.go @@ -125,6 +125,14 @@ func Test_slimApiNameResolver_FillMethod(t *testing.T) { callback: "", }) + // Content-Type 分号后的部分被忽略。 + testOne("?~method=name&multi=1", webapi.ContentTypeMultipartForm+"; boundary=----123", want{ + name: "name", + requestFormat: meta_RequestFormat_Post, + responseContentType: webapi.ContentTypeJson, + callback: "", + }) + // Content-Type 分后后的部分被忽略。 testOne("?~method=name&with_charset=1", webapi.ContentTypeForm+"; charset=utf8", want{ name: "name",