From 083eb4417a04201f1eb755faab8ee7121b3c7f16 Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期五, 17 十一月 2023 16:19:05 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/igds-api-gateway' into igds-api-gateway
---
src/main/java/com/fzzy/push/gb2022/HttpClientUtil.java | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/fzzy/push/gb2022/HttpClientUtil.java b/src/main/java/com/fzzy/push/gb2022/HttpClientUtil.java
index b1484ff..b52cd8e 100644
--- a/src/main/java/com/fzzy/push/gb2022/HttpClientUtil.java
+++ b/src/main/java/com/fzzy/push/gb2022/HttpClientUtil.java
@@ -21,14 +21,15 @@
/**
* post formData
+ *
* @param url
* @param map
* @return
* @throws Exception
*/
@SuppressWarnings("resource")
- public static ResponseDto postFormData(String url, Map<String, Object> map) throws Exception {
- log.info("---------鎺ュ彛璇锋眰鍦板潃锛�" +url+ "----------鍙傛暟锛�" + JSON.toJSONString(map) +"---------");
+ public static ResponseDto postFormData(String url, Map<String, Object> map) throws Exception {
+ log.info("---------鎺ュ彛璇锋眰鍦板潃锛�" + url + "----------鍙傛暟锛�" + JSON.toJSONString(map) + "---------");
BufferedReader in = null;
URL urls = new URL(url);
HttpURLConnection connection = null;
@@ -47,10 +48,10 @@
connection.setConnectTimeout(20000);
connection.setReadTimeout(30000);
connection.setRequestMethod("POST");
- if(StringUtils.isNotEmpty(JSESSIONID)){
+ if (StringUtils.isNotEmpty(JSESSIONID)) {
// connection.setRequestProperty("Cookie", "JSESSIONID="+JSESSIONID);
// connection.setRequestProperty(" Set-Cookies", JSESSIONID);
- connection.setRequestProperty("Cookie", "JSESSIONID="+JSESSIONID);
+ connection.setRequestProperty("Cookie", "JSESSIONID=" + JSESSIONID);
}
map.remove("JSESSIONID");
@@ -76,7 +77,7 @@
// System.out.println(buffer.toString());
outputStream.write(buffer.toString().getBytes());
File file = (File) entry.getValue();
- DataInputStream ins = new DataInputStream(new FileInputStream(file));
+ DataInputStream ins = new DataInputStream(new FileInputStream(file));
int bytes = 0;
byte[] bufferOut = new byte[1024];
while ((bytes = ins.read(bufferOut)) != -1) {
@@ -102,7 +103,7 @@
while ((line = in.readLine()) != null) {
rs += line;
}
- }else{
+ } else {
log.error("http鐘舵�侊細" + connection.getResponseCode());
log.error("http娑堟伅锛�" + connection.getResponseMessage());
}
@@ -110,7 +111,7 @@
String serverCookies = connection.getHeaderField("Set-Cookie");
log.info("serverCookies:" + serverCookies);
- if(serverCookies != null) {
+ if (serverCookies != null) {
String[] cookies = serverCookies.split(";");
@@ -128,19 +129,19 @@
} catch (Exception e) {
System.out.println("鍙戠敓寮傚父");
- log.error(e.getMessage(),e);
+ log.error(e.getMessage(), e);
rs = null;
- return new ResponseDto(99,e.getMessage());
+ return new ResponseDto(99, e.getMessage());
}
- log.info("---------鎺ュ彛杩斿洖锛�" + rs +"---------");
- responseDto = JSON.parseObject(rs,ResponseDto.class);
- if(responseDto == null ) return new ResponseDto(99,"鎺ュ彛璇锋眰鍙戠敓鏈煡閿欒");
+ log.info("---------鎺ュ彛杩斿洖锛�" + rs + "---------");
+ responseDto = JSON.parseObject(rs, ResponseDto.class);
+ if (responseDto == null) return new ResponseDto(99, "鎺ュ彛璇锋眰鍙戠敓鏈煡閿欒");
responseDto.setJSESSIONID(JSESSIONID);
return responseDto;
} finally {
try {
outputStream.close();
- if (in != null){
+ if (in != null) {
in.close();
}
} catch (Exception e) {
--
Gitblit v1.9.3