From 8270406d3c98657dd081bdb6d9a110149d1d2597 Mon Sep 17 00:00:00 2001 From: chenzhihang <709011834@qq.com> Date: Mon, 19 May 2025 20:06:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96http=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/platform/utils/NewHttpUtils.java | 8 +++++- .../ruoyi/platform/vo/HttpDeleteWithBody.java | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/HttpDeleteWithBody.java diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/NewHttpUtils.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/NewHttpUtils.java index dc88ad0e..f48f48f5 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/NewHttpUtils.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/utils/NewHttpUtils.java @@ -1,5 +1,7 @@ package com.ruoyi.platform.utils; +import com.ruoyi.common.core.utils.StringUtils; +import com.ruoyi.platform.vo.HttpDeleteWithBody; import org.apache.http.HttpHost; import org.apache.http.client.methods.*; import org.apache.http.client.utils.URIBuilder; @@ -80,7 +82,11 @@ public class NewHttpUtils { } public static String sendDeleteWithToken(String url, String param, String token, String body) throws Exception { - return sendRequest(new HttpDelete(), url, param, token, body); + if (StringUtils.isNotEmpty(body)) { + return sendRequest(new HttpDeleteWithBody(), url, param, token, body); + } else { + return sendRequest(new HttpDelete(), url, param, token, body); + } } public static String sendPatchWithToken(String url, String param, String token, String body) throws Exception { diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/HttpDeleteWithBody.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/HttpDeleteWithBody.java new file mode 100644 index 00000000..340efa52 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/HttpDeleteWithBody.java @@ -0,0 +1,25 @@ +package com.ruoyi.platform.vo; + +import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; + +import java.net.URI; + +public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { + public static final String METHOD_NAME = "DELETE"; + + public HttpDeleteWithBody() { + } + + public HttpDeleteWithBody(URI uri) { + this.setURI(uri); + } + + public HttpDeleteWithBody(String uri) { + this.setURI(URI.create(uri)); + } + + @Override + public String getMethod() { + return METHOD_NAME; + } +}