mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
使用multiparty方式支持body参数
This commit is contained in:
parent
89056a3d71
commit
2eb8f9c969
@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.21(2023-07-05)
|
||||
# 5.8.21(2023-07-08)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 list 为空时,CollUtil.max等返回null而非异常(pr#1027@Gitee)
|
||||
@ -12,6 +12,7 @@
|
||||
* 【core 】 RandomUtil增加可选是否包含边界的重载(issue#3182@Github)
|
||||
* 【core 】 StrUtil增加truncateByByteLength方法(pr#3176@Github)
|
||||
* 【core 】 身份证工具类isValidCard18、isValidCard15入参null直接返回null(pr#1034@Gitee)
|
||||
* 【http 】 使用multiparty方式支持body参数(issue#3158@Gitee)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【core 】 修复MapUtil工具使用filter方法构造传入参数结果问题(issue#3162@Github)
|
||||
|
@ -1379,10 +1379,18 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
private void sendMultipart() throws IOException {
|
||||
final MultipartBody multipartBody = MultipartBody.create(this.form, this.charset);
|
||||
//设置表单类型为Multipart(文件上传)
|
||||
this.httpConnection.header(Header.CONTENT_TYPE, multipartBody.getContentType(), true);
|
||||
multipartBody.writeClose(this.httpConnection.getOutputStream());
|
||||
final RequestBody body;
|
||||
// issue#3158,当用户自定义为multipart同时传入body,则不做单独处理
|
||||
if(null == form && null != this.body) {
|
||||
body = ResourceBody.create(this.body);
|
||||
}else{
|
||||
final MultipartBody multipartBody = MultipartBody.create(this.form, this.charset);
|
||||
//设置表单类型为Multipart(文件上传)
|
||||
this.httpConnection.header(Header.CONTENT_TYPE, multipartBody.getContentType(), true);
|
||||
body = multipartBody;
|
||||
}
|
||||
|
||||
body.writeClose(this.httpConnection.getOutputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user