From f5318c6daddc1114f40119e0030dcde56819c8e3 Mon Sep 17 00:00:00 2001 From: huangzhiquan <6498754713@qq.com> Date: Wed, 15 Jun 2022 14:59:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=201.HttpResponse=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AEbodyBytes=E5=82=A8=E5=AD=98=E4=B8=BB=E4=BD=93?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=88=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8?= =?UTF-8?q?HttpResponse=E6=8B=A6=E6=88=AA=E5=99=A8=E8=A7=A3=E5=AF=86?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E9=87=8D=E6=96=B0=E8=AE=BE=E7=BD=AEbodyBytes?= =?UTF-8?q?=E4=B8=BB=E4=BD=93=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/hutool/http/HttpResponse.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java b/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java index 21f018f2b..a4439b527 100755 --- a/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpResponse.java @@ -255,6 +255,21 @@ public class HttpResponse extends HttpBase implements Closeable { return this.bodyBytes; } + /** + * 设置主体字节码
+ * 需在此方法调用前使用charset方法设置编码,否则使用默认编码UTF-8 + * + * @param bodyBytes 主体 + * @return this + */ + public HttpResponse body(byte[] bodyBytes) { + sync(); + if (null != bodyBytes) { + this.bodyBytes = bodyBytes; + } + return this; + } + /** * 获取响应主体 *