mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-03 20:27:58 +08:00
add setChunkedStreamingMode method
This commit is contained in:
parent
7ca33d1602
commit
d3fff05b95
@ -15,6 +15,7 @@
|
|||||||
* 【json】 添加自定义序列化反序列化支持(issue#I1052A@Gitee)
|
* 【json】 添加自定义序列化反序列化支持(issue#I1052A@Gitee)
|
||||||
* 【dfa】 优化特殊字符构建,优化查找,改为使用StrBuilder
|
* 【dfa】 优化特殊字符构建,优化查找,改为使用StrBuilder
|
||||||
* 【core】 ZipUtil增加FileFilter参数的重载,支持文件过滤(issue#I11RTP@Gitee)
|
* 【core】 ZipUtil增加FileFilter参数的重载,支持文件过滤(issue#I11RTP@Gitee)
|
||||||
|
* 【http】 HttpRequest增加setChunkedStreamingMode方法(issue#525@Github)
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
* 【core】 修复NetUtil.getUsableLocalPort问题(pr#69@Gitee)
|
* 【core】 修复NetUtil.getUsableLocalPort问题(pr#69@Gitee)
|
||||||
|
@ -349,11 +349,13 @@ public class HttpConnection {
|
|||||||
* 采用流方式上传数据,无需本地缓存数据。<br>
|
* 采用流方式上传数据,无需本地缓存数据。<br>
|
||||||
* HttpUrlConnection默认是将所有数据读到本地缓存,然后再发送给服务器,这样上传大文件时就会导致内存溢出。
|
* HttpUrlConnection默认是将所有数据读到本地缓存,然后再发送给服务器,这样上传大文件时就会导致内存溢出。
|
||||||
*
|
*
|
||||||
* @param blockSize 块大小(bytes数)
|
* @param blockSize 块大小(bytes数),0或小于0表示不设置Chuncked模式
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public HttpConnection setChunkedStreamingMode(int blockSize) {
|
public HttpConnection setChunkedStreamingMode(int blockSize) {
|
||||||
|
if(blockSize > 0) {
|
||||||
conn.setChunkedStreamingMode(blockSize);
|
conn.setChunkedStreamingMode(blockSize);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +123,8 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
|||||||
private int redirectCount;
|
private int redirectCount;
|
||||||
/** 最大重定向次数 */
|
/** 最大重定向次数 */
|
||||||
private int maxRedirectCount;
|
private int maxRedirectCount;
|
||||||
|
/** Chuncked块大小,0或小于0表示不设置Chuncked模式 */
|
||||||
|
private int blockSize;
|
||||||
/** 代理 */
|
/** 代理 */
|
||||||
private Proxy proxy;
|
private Proxy proxy;
|
||||||
|
|
||||||
@ -858,6 +860,19 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采用流方式上传数据,无需本地缓存数据。<br>
|
||||||
|
* HttpUrlConnection默认是将所有数据读到本地缓存,然后再发送给服务器,这样上传大文件时就会导致内存溢出。
|
||||||
|
*
|
||||||
|
* @param blockSize 块大小(bytes数),0或小于0表示不设置Chuncked模式
|
||||||
|
* @return this
|
||||||
|
* @since 4.6.5
|
||||||
|
*/
|
||||||
|
public HttpRequest setChunkedStreamingMode(int blockSize) {
|
||||||
|
this.blockSize = blockSize;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行Reuqest请求
|
* 执行Reuqest请求
|
||||||
*
|
*
|
||||||
@ -946,6 +961,8 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
|||||||
.setCookie(this.cookie)
|
.setCookie(this.cookie)
|
||||||
// 定义转发
|
// 定义转发
|
||||||
.setInstanceFollowRedirects(this.maxRedirectCount > 0 ? true : false)
|
.setInstanceFollowRedirects(this.maxRedirectCount > 0 ? true : false)
|
||||||
|
// 流方式上传数据
|
||||||
|
.setChunkedStreamingMode(this.blockSize)
|
||||||
// 覆盖默认Header
|
// 覆盖默认Header
|
||||||
.header(this.headers, true);
|
.header(this.headers, true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user