From 97019f79b5667acdd97481a27211da7a9ce669fa Mon Sep 17 00:00:00 2001 From: wenlianggong Date: Tue, 25 Jun 2024 20:43:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8BtestHttpResource?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/hutool/http/HttpRequestTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hutool-http/src/test/java/cn/hutool/http/HttpRequestTest.java b/hutool-http/src/test/java/cn/hutool/http/HttpRequestTest.java index 06d777bc5..44a09b528 100644 --- a/hutool-http/src/test/java/cn/hutool/http/HttpRequestTest.java +++ b/hutool-http/src/test/java/cn/hutool/http/HttpRequestTest.java @@ -2,6 +2,7 @@ package cn.hutool.http; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.TimeInterval; +import cn.hutool.core.io.resource.StringResource; import cn.hutool.core.lang.Console; import cn.hutool.core.net.SSLProtocols; import cn.hutool.core.net.url.UrlBuilder; @@ -240,4 +241,19 @@ public class HttpRequestTest { final HttpResponse httpResponse = HttpRequest.get("http://82.157.17.173:8100/app/getAddress").execute(); Console.log(httpResponse.body()); } + + @Test + @Ignore + public void testHttpResource() { + + HttpRequest httpRequest = HttpRequest.post("http://127.0.0.1:8080/testHttpResource"); + HttpResponse response = httpRequest.form("user", new HttpResource(new StringResource("{\n" + + " \"name\": \"张三\",\n" + + " \"age\": \"16\"\n" + + "}"), "application/json")) + .form("passport", "12456") + .execute(); + Console.log(response.body()); + + } }