xgfone / ship

A flexible, powerful, high performance and minimalist Go Web HTTP router framework.
https://github.com/xgfone/ship
Apache License 2.0
48 stars 5 forks source link

获取 Content-Type 的小问题 #16

Open xmx opened 1 year ago

xmx commented 1 year ago

https://github.com/xgfone/ship/blob/405a71df982a3bdd7fd2925b85610949cad78d6c/context.go#L410-L417 https://github.com/xgfone/ship/blob/405a71df982a3bdd7fd2925b85610949cad78d6c/binder.go#L72-L83

上面两处代码在获取 Content-Type 时用的是 index > 0,如果测试用例是 ; charset=utf-8,那么切割出的 Content-Type; charset=utf-8。此时我们期望结果的应该是 空字符串

故:此处使用 index >= 0 更为妥当