From 41e3037d4b5b2fdb08836e17671b9488445b5a5b Mon Sep 17 00:00:00 2001 From: Looly Date: Wed, 4 Sep 2024 17:22:25 +0800 Subject: [PATCH] fix code --- .../main/java/org/dromara/hutool/http/client/Request.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hutool-http/src/main/java/org/dromara/hutool/http/client/Request.java b/hutool-http/src/main/java/org/dromara/hutool/http/client/Request.java index 1ed86f1ef..420e21d6d 100644 --- a/hutool-http/src/main/java/org/dromara/hutool/http/client/Request.java +++ b/hutool-http/src/main/java/org/dromara/hutool/http/client/Request.java @@ -384,7 +384,11 @@ public class Request implements HeaderOperation { // 根据内容赋值默认Content-Type if (StrUtil.isBlank(header(HeaderName.CONTENT_TYPE))) { - header(HeaderName.CONTENT_TYPE, body.contentType(charset()), true); + final String contentType = body.contentType(charset()); + // 如果用户自定义的Header为null,不调用,防止实现类中可能的空指针问题 + if(null != contentType){ + header(HeaderName.CONTENT_TYPE, contentType, true); + } } return this;