From bba5906118fdeb360c764fb5bdacd4ef22c8d7dc Mon Sep 17 00:00:00 2001 From: Looly Date: Fri, 6 Sep 2024 17:58:57 +0800 Subject: [PATCH] add test --- .../cn/hutool/http/server/Issue3723Test.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 hutool-http/src/test/java/cn/hutool/http/server/Issue3723Test.java diff --git a/hutool-http/src/test/java/cn/hutool/http/server/Issue3723Test.java b/hutool-http/src/test/java/cn/hutool/http/server/Issue3723Test.java new file mode 100644 index 000000000..1c9d151d8 --- /dev/null +++ b/hutool-http/src/test/java/cn/hutool/http/server/Issue3723Test.java @@ -0,0 +1,22 @@ +package cn.hutool.http.server; + +import cn.hutool.core.util.IdUtil; +import cn.hutool.http.ContentType; +import cn.hutool.http.HttpUtil; + +public class Issue3723Test { + public static void main(String[] args) { + SimpleServer server = HttpUtil.createServer(8888); + server.addFilter((req, res, chain) -> { + String requestId = IdUtil.fastSimpleUUID(); + req.getHttpExchange().setAttribute("requestId", requestId); + res.addHeader("X-Request-Id", requestId); + + res.write("new Content"); + + chain.doFilter(req.getHttpExchange()); + }); + server.addAction("/", (req, res)-> res.write("Hello Hutool Server", ContentType.JSON.getValue())); + server.start(); + } +}