This commit is contained in:
Looly 2022-02-10 00:17:25 +08:00
parent 9b01a23a60
commit 7116177225
3 changed files with 13 additions and 2 deletions

View File

@ -2,7 +2,7 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.7.21 (2022-02-07)
# 5.7.21 (2022-02-10)
### 🐣新特性
* 【extra 】 增加jetbrick模板支持
@ -24,6 +24,7 @@
* 【extra 】 修复EmojiUtil.toHtmlHex()方法pr#519@Gitee
* 【system 】 修复CpuInfo.getUsed()方法issue#2116@Github
* 【dfa 】 修复密集匹配和贪婪匹配冲突问题issue#2126@Github
* 【http 】 修复Action中HttpExchange没有关闭问题
-------------------------------------------------------------------------------------------------------------
# 5.7.20 (2022-01-20)

View File

@ -4,6 +4,7 @@ import cn.hutool.core.util.CharsetUtil;
import com.sun.net.httpserver.HttpContext;
import com.sun.net.httpserver.HttpExchange;
import java.io.Closeable;
import java.nio.charset.Charset;
/**
@ -12,7 +13,7 @@ import java.nio.charset.Charset;
* @author looly
* @since 5.2.6
*/
public class HttpServerBase {
public class HttpServerBase implements Closeable {
final static Charset DEFAULT_CHARSET = CharsetUtil.CHARSET_UTF_8;
@ -45,4 +46,12 @@ public class HttpServerBase {
public HttpContext getHttpContext() {
return getHttpExchange().getHttpContext();
}
/**
* 调用{@link HttpExchange#close()}关闭请求流和响应流
*/
@Override
public void close() {
this.httpExchange.close();
}
}

View File

@ -33,5 +33,6 @@ public class ActionHandler implements HttpHandler {
new HttpServerRequest(httpExchange),
new HttpServerResponse(httpExchange)
);
httpExchange.close();
}
}