Skip to content

Commit

Permalink
bug fix:使用 Content-Type: multipart/form-data 格式的请求时, body 部分的参数不能被正确解析。
Browse files Browse the repository at this point in the history
  • Loading branch information
cmstar committed Jun 5, 2023
1 parent 3515b8b commit 7cf5f38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions slimapi/slimapi_name_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 是对应回执的,需单独处理。
Expand Down
8 changes: 8 additions & 0 deletions slimapi/slimapi_name_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7cf5f38

Please sign in to comment.