From 97a17d0849a1b76ed99dee09d371bb6afa2c7bd1 Mon Sep 17 00:00:00 2001 From: lawrencehj <1934378145@qq.com> Date: Tue, 22 Jun 2021 11:54:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=94=A8=E6=88=B7=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E6=92=AD=E6=94=BE=E5=90=8EAPI=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E6=8A=9B=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/conf/ProxyServletConfig.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java index 06d62df4..3c4ea172 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java @@ -2,8 +2,7 @@ package com.genersoft.iot.vmp.conf; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.catalina.connector.ClientAbortException; import org.mitre.dsmiley.httpproxy.ProxyServlet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,16 +13,11 @@ import org.springframework.context.annotation.Configuration; import org.springframework.util.StringUtils; import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.ConnectException; -import java.util.Locale; -import java.util.Map; - +@SuppressWarnings(value = {"rawtypes", "unchecked"}) @Configuration public class ProxyServletConfig { @@ -61,7 +55,7 @@ public class ProxyServletConfig { @Override protected void handleRequestException(HttpRequest proxyRequest, HttpResponse proxyResonse, Exception e){ - System.out.println(e.getMessage()); + //System.out.println(e.getMessage()); try { super.handleRequestException(proxyRequest, proxyResonse, e); } catch (ServletException servletException) { @@ -69,7 +63,9 @@ public class ProxyServletConfig { } catch (IOException ioException) { if (ioException instanceof ConnectException) { logger.error("zlm 连接失败"); - }else { + } else if (ioException instanceof ClientAbortException) { + logger.error("用户已中断连接,代理终止"); + } else { logger.error("zlm 代理失败: ", e); } } catch (RuntimeException exception){