mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
HttpRequest增加setFixedLengthStreamingMode方法
This commit is contained in:
parent
6ebca582f1
commit
b00844e896
@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.33(2024-09-11)
|
||||
# 5.8.33(2024-09-13)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 SyncFinisher增加setExecutorService方法(issue#IANKQ1@Gitee)
|
||||
@ -11,6 +11,7 @@
|
||||
* 【crypto 】 SM2解密时,兼容GmSSL非压缩省略的04头的密文(issue#IAP1QJ@Gitee)
|
||||
* 【core 】 兼容NumberUtil.add方法传入整型自动类型转换为浮点类型的精度丢失问题(pr#3721@Github)
|
||||
* 【core 】 ModifierUtil明确注释,并增加hasAllModifiers方法(issue#IAQ2U0@Gitee)
|
||||
* 【http 】 HttpRequest增加setFixedLengthStreamingMode方法(issue#3462@Github)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【json 】 修复JSONConfig.setDateFormat设置后toBean无效问题(issue#3713@Github)
|
||||
|
@ -351,6 +351,20 @@ public class HttpConnection {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置固定长度流模式,默认为0,表示不设置固定长度流模式,即默认为按需发送数据长度。<br>
|
||||
* 当发送大文件时,如果每次发送的数据长度不一致,可能造成接收方无法正常接收,此时可以设置固定长度流模式,此时发送的数据长度为contentLength,不足部分用0补齐。
|
||||
*
|
||||
* @param contentLength 固定长度
|
||||
* @return this
|
||||
*/
|
||||
public HttpConnection setFixedLengthStreamingMode(long contentLength){
|
||||
if(contentLength > 0){
|
||||
conn.setFixedLengthStreamingMode(contentLength);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 采用流方式上传数据,无需本地缓存数据。<br>
|
||||
* HttpUrlConnection默认是将所有数据读到本地缓存,然后再发送给服务器,这样上传大文件时就会导致内存溢出。
|
||||
|
@ -350,6 +350,19 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
return this.httpConnection;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置固定长度流模式,默认为0,表示不设置固定长度流模式,即默认为按需发送数据长度。<br>
|
||||
* 当发送大文件时,如果每次发送的数据长度不一致,可能造成接收方无法正常接收,此时可以设置固定长度流模式,此时发送的数据长度为contentLength,不足部分用0补齐。
|
||||
*
|
||||
* @param contentLength 固定长度
|
||||
* @return this
|
||||
* @since 5.8.33
|
||||
*/
|
||||
public HttpRequest setFixedLengthStreamingMode(long contentLength){
|
||||
this.httpConnection.setFixedLengthStreamingMode(contentLength);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置请求方法
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user