From e183d5378720caef772be6c88c64dd57a04ba62d Mon Sep 17 00:00:00 2001 From: Looly Date: Wed, 31 Jul 2024 00:23:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BContentType.get=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + hutool-http/src/main/java/cn/hutool/http/ContentType.java | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) 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 '[':