From e1aaea4eed76a5c4580d61aa91171d529df889b0 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 30 Oct 2024 15:54:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9Message=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9A=84=E5=BC=82=E5=B8=B8,=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D400=E9=94=99=E8=AF=AF=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/request/SIPRequestProcessorParent.java | 10 +++++----- .../event/request/impl/SubscribeRequestProcessor.java | 1 + .../request/impl/message/MessageRequestProcessor.java | 5 ----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java index 990e788b..bfc7e23b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java @@ -170,10 +170,14 @@ public abstract class SIPRequestProcessorParent { } public Element getRootElement(RequestEvent evt, String charset) throws DocumentException { + byte[] rawContent = evt.getRequest().getRawContent(); + if (rawContent == null) { + return null; + } + if (charset == null) { charset = "gb2312"; } - Request request = evt.getRequest(); SAXReader reader = new SAXReader(); reader.setEncoding(charset); // 对海康出现的未转义字符做处理。 @@ -182,10 +186,6 @@ public abstract class SIPRequestProcessorParent { char despChar = '&'; byte destBye = (byte) despChar; List result = new ArrayList<>(); - byte[] rawContent = request.getRawContent(); - if (rawContent == null) { - return null; - } for (int i = 0; i < rawContent.length; i++) { if (rawContent[i] == destBye) { boolean resul = false; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index 39d04c13..acdff1ce 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -68,6 +68,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme Element rootElement = getRootElement(evt); if (rootElement == null) { log.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest()); + responseAck(request, Response.BAD_REQUEST); return; } String cmd = XmlUtil.getText(rootElement, "CmdType"); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index 8ad042bb..237eab16 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -102,11 +102,6 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement sipEvent.getErrorEvent().response(eventResult); } }else { - byte[] rawContent = request.getRawContent(); - if (rawContent == null) { - responseAck(request, Response.BAD_REQUEST, "content is null"); - return; - } Element rootElement; try { rootElement = getRootElement(evt);