From 4a349f04abb665c0e99930bc1ef1c54ef24614f7 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 04 九月 2023 08:43:41 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/utils/NyHttpUtils.java | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/NyHttpUtils.java b/src/main/java/com/zy/common/utils/NyHttpUtils.java
index 12d8c2c..be86a96 100644
--- a/src/main/java/com/zy/common/utils/NyHttpUtils.java
+++ b/src/main/java/com/zy/common/utils/NyHttpUtils.java
@@ -5,6 +5,7 @@
import com.zy.common.model.NavigateNode;
import com.zy.core.model.command.NyShuttleHttpCommand;
import com.zy.core.model.protocol.NyShuttleProtocol;
+import springfox.documentation.spring.web.json.Json;
import java.io.*;
import java.net.Socket;
@@ -303,14 +304,32 @@
}
} while (response != null);
// System.out.println("Received response from server: " + sb);
- return JSON.parseObject(sb.toString());
+
+ JSONObject result = JSON.parseObject(sb.toString());//寰楀埌鍝嶅簲缁撴灉闆�
+ if (!result.get("msgType").equals("responseMsg")) {//涓嶆槸鍝嶅簲鍐呭
+ return null;
+ }
+
+ JSONObject resultResponse = JSON.parseObject(result.get("response").toString());
+ JSONObject resultHeader = JSON.parseObject(resultResponse.get("header").toString());
+ int responseId = Integer.parseInt(resultHeader.get("responseId").toString());
+// if (responseId != httpCommand.getRequest().getHeader().getRequestId()) {
+// return null;//鍝嶅簲ID涓庤姹侷D涓嶄竴鑷�
+// }
+
+ return filterBodyData(result);//杩斿洖Body缁撴灉闆�
} catch (Exception e) {
e.printStackTrace();
+ try {
+ socket.close();
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ }
}
return null;
}
- public static JSONObject filterData(JSONObject data) {
+ public static JSONObject filterBodyData(JSONObject data) {
Object response = data.get("response");
if (response == null) {
return null;
--
Gitblit v1.9.1