From 2b0a0d3a20bdf7e85ade6c459a4415011d32ea98 Mon Sep 17 00:00:00 2001 From: 502647092 Date: Tue, 25 Jul 2017 16:45:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- .../java/pw/yumc/YumCore/kit/HttpKit.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/pw/yumc/YumCore/kit/HttpKit.java b/src/main/java/pw/yumc/YumCore/kit/HttpKit.java index c54bd66..0b36e23 100644 --- a/src/main/java/pw/yumc/YumCore/kit/HttpKit.java +++ b/src/main/java/pw/yumc/YumCore/kit/HttpKit.java @@ -142,16 +142,19 @@ public class HttpKit { */ @SneakyThrows public static String send(HttpInfo info) { - @Cleanup HttpURLConnection conn = getHttpConnection(buildUrlWithQueryString(info), info.getMethod().name(), info.getHeader()); - conn.connect(); - if (StrKit.notBlank(info.getData())) { - OutputStream out = conn.getOutputStream(); - out.write(info.getData().getBytes(CHARSET)); - out.flush(); - out.close(); + try { + conn.connect(); + if (StrKit.notBlank(info.getData())) { + OutputStream out = conn.getOutputStream(); + out.write(info.getData().getBytes(CHARSET)); + out.flush(); + out.close(); + } + return readResponseString(conn); + } finally { + conn.disconnect(); } - return readResponseString(conn); } @Data