diff --git a/CHANGELOG.md b/CHANGELOG.md index 617eb1f13..9a4d78033 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * 【core 】 Opt增加ifFail(pr#1239@Gitee) * 【poi 】 增加GlobalPoiConfig(issue#IAEHJH@Gitee) * 【core 】 优化IndexedComparator性能(pr#1240@Gitee) +* 【http 】 改进ContentType.get忽略空格(pr#3664@Github) ### 🐞Bug修复 * 【core 】 修复因RFC3986理解有误导致的UrlPath处理冒号转义问题(issue#IAAE88@Gitee) diff --git a/hutool-http/src/main/java/cn/hutool/http/ContentType.java b/hutool-http/src/main/java/cn/hutool/http/ContentType.java index 6b57681b0..75f474b11 100644 --- a/hutool-http/src/main/java/cn/hutool/http/ContentType.java +++ b/hutool-http/src/main/java/cn/hutool/http/ContentType.java @@ -120,8 +120,7 @@ public enum ContentType { public static ContentType get(String body) { ContentType contentType = null; if (StrUtil.isNotBlank(body)) { - body = StrUtil.trim(body); - char firstChar = body.charAt(0); + char firstChar = StrUtil.trimStart(body).charAt(0); switch (firstChar) { case '{': case '[':