mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
修复graalvm编译后,未读取Content-Length可能导致的读取时间过长问题
This commit is contained in:
parent
b8f3529238
commit
d46f00d2be
@ -21,6 +21,7 @@
|
|||||||
* 【cache 】 修复StampedCache的get方法非原子问题(issue#I8MEIX@Gitee)
|
* 【cache 】 修复StampedCache的get方法非原子问题(issue#I8MEIX@Gitee)
|
||||||
* 【core 】 修复StrSplitter.splitByRegex使用空参数导致的OOM问题(issue#3421@Github)
|
* 【core 】 修复StrSplitter.splitByRegex使用空参数导致的OOM问题(issue#3421@Github)
|
||||||
* 【db 】 修复嵌套SQL中order by子句错误截断问题(issue#I89RXV@Gitee)
|
* 【db 】 修复嵌套SQL中order by子句错误截断问题(issue#I89RXV@Gitee)
|
||||||
|
* 【http 】 修复graalvm编译后,未读取Content-Length可能导致的读取时间过长问题(issue#I6Q30X@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
# 5.8.23(2023-11-12)
|
# 5.8.23(2023-11-12)
|
||||||
|
@ -3,6 +3,7 @@ package cn.hutool.http.server;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.io.IORuntimeException;
|
import cn.hutool.core.io.IORuntimeException;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.core.io.LimitedInputStream;
|
||||||
import cn.hutool.core.map.CaseInsensitiveMap;
|
import cn.hutool.core.map.CaseInsensitiveMap;
|
||||||
import cn.hutool.core.map.multi.ListValueMap;
|
import cn.hutool.core.map.multi.ListValueMap;
|
||||||
import cn.hutool.core.net.NetUtil;
|
import cn.hutool.core.net.NetUtil;
|
||||||
@ -294,7 +295,24 @@ public class HttpServerRequest extends HttpServerBase {
|
|||||||
* @return 流
|
* @return 流
|
||||||
*/
|
*/
|
||||||
public InputStream getBodyStream() {
|
public InputStream getBodyStream() {
|
||||||
return this.httpExchange.getRequestBody();
|
InputStream bodyStream = this.httpExchange.getRequestBody();
|
||||||
|
|
||||||
|
//issue#I6Q30X,读取body长度,避免读取结束后无法正常结束问题
|
||||||
|
final String contentLengthStr = getHeader(Header.CONTENT_LENGTH);
|
||||||
|
long contentLength = 0;
|
||||||
|
if(StrUtil.isNotBlank(contentLengthStr)){
|
||||||
|
try{
|
||||||
|
contentLength = Long.parseLong(contentLengthStr);
|
||||||
|
} catch (final NumberFormatException ignore){
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(contentLength > 0){
|
||||||
|
bodyStream = new LimitedInputStream(bodyStream, contentLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bodyStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user