From 4aea2ef471fa2844bea09544970ed7aebbd38a85 Mon Sep 17 00:00:00 2001 From: Looly Date: Wed, 7 May 2025 10:41:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`HttpClient5Response`?= =?UTF-8?q?=E6=97=A0=E5=93=8D=E5=BA=94=E4=BD=93=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E9=97=AE=E9=A2=98=EF=BC=88issue#393?= =?UTF-8?q?0@Github=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 +----- .../client/engine/httpclient5/HttpClient5Response.java | 8 +++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2286527c..17a1d8fa1 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,7 @@ ------------------------------------------------------------------------------------------------------------- -# 6.0.0-M17 (2024-10-09) - -### 计划实现 -* 【db 】 增加DDL封装 -* 【db 】 Entity数据量大时占用较多内存,考虑共享meta信息 +# 6.0.0-M22 (2025-05-07) ### ❌不兼容特性 diff --git a/hutool-http/src/main/java/org/dromara/hutool/http/client/engine/httpclient5/HttpClient5Response.java b/hutool-http/src/main/java/org/dromara/hutool/http/client/engine/httpclient5/HttpClient5Response.java index e3ca99e4d..0eead2108 100644 --- a/hutool-http/src/main/java/org/dromara/hutool/http/client/engine/httpclient5/HttpClient5Response.java +++ b/hutool-http/src/main/java/org/dromara/hutool/http/client/engine/httpclient5/HttpClient5Response.java @@ -96,7 +96,7 @@ public class HttpClient5Response extends SimpleWrapper impl @Override public long contentLength() { - return this.entity.getContentLength(); + return null == this.entity ? -1 : this.entity.getContentLength(); } @Override @@ -106,6 +106,9 @@ public class HttpClient5Response extends SimpleWrapper impl @Override public InputStream bodyStream() { + if(null == this.entity){ + return null; + } try { return this.entity.getContent(); } catch (final IOException e) { @@ -130,6 +133,9 @@ public class HttpClient5Response extends SimpleWrapper impl @Override public String bodyStr() throws HttpException { + if(null == this.entity){ + return null; + } try { return EntityUtils.toString(this.entity, charset()); } catch (final IOException e) {