From 8c4d40be22a45183b11515888c2b8aa40e8ba7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E4=B8=B9?= <13207025+actri_tdan_admin@user.noreply.gitee.com> Date: Fri, 28 Jul 2023 08:22:52 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8D=95=E8=8E=B7=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=EF=BC=9A=E5=9C=A8=E5=A4=84=E7=90=86=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=97=B6=EF=BC=8C=E5=8F=AF=E8=83=BD=E4=BC=9A?= =?UTF-8?q?=E9=81=87=E5=88=B0=E5=90=84=E7=A7=8D=E5=BC=82=E5=B8=B8=E6=83=85?= =?UTF-8?q?=E5=86=B5=EF=BC=8C=E4=BE=8B=E5=A6=82=E8=BF=9E=E6=8E=A5=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E3=80=81=E8=AF=B7=E6=B1=82=E9=94=99=E8=AF=AF=E7=AD=89?= =?UTF-8?q?=E3=80=82=E5=BA=94=E8=AF=A5=E9=80=82=E5=BD=93=E6=8D=95=E8=8E=B7?= =?UTF-8?q?=E8=BF=99=E4=BA=9B=E5=BC=82=E5=B8=B8=E5=B9=B6=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E9=81=BF=E5=85=8D=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=B4=A9=E6=BA=83=E6=88=96=E6=97=A0=E5=93=8D=E5=BA=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 田丹 <13207025+actri_tdan_admin@user.noreply.gitee.com> --- src/net/oschina/git/utils/HttpUtil.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/net/oschina/git/utils/HttpUtil.java b/src/net/oschina/git/utils/HttpUtil.java index 00257eb..7acb7b2 100644 --- a/src/net/oschina/git/utils/HttpUtil.java +++ b/src/net/oschina/git/utils/HttpUtil.java @@ -48,13 +48,15 @@ public class HttpUtil { String responseHtml = EntityUtils.toString(response.getEntity()); return responseHtml; } - public static String get(String url) throws ClientProtocolException, IOException{ + public static String get(String url) throws ClientProtocolException, IOException { HttpGet hg = new HttpGet(url); - for(String st:header.keySet()){ - hg.setHeader(st, header.get(st)); + for (String st : getDefaultHeaders().keySet()) { + hg.setHeader(st, getDefaultHeaders().get(st)); + } + try (CloseableHttpClient httpClient = getHttpClient()) { + HttpResponse response = httpClient.execute(hg); + String responseHtml = EntityUtils.toString(response.getEntity()); + return responseHtml; } - HttpResponse response = httpclient.execute(hg); - String responseHtml = EntityUtils.toString(response.getEntity()); - return responseHtml; } } -- Gitee