兼容Message缺少消息的异常,回复400错误码

pull/1669/head
648540858 2024-10-30 15:54:53 +08:00
parent da18081fca
commit e1aaea4eed
3 changed files with 6 additions and 10 deletions

View File

@ -170,10 +170,14 @@ public abstract class SIPRequestProcessorParent {
} }
public Element getRootElement(RequestEvent evt, String charset) throws DocumentException { public Element getRootElement(RequestEvent evt, String charset) throws DocumentException {
byte[] rawContent = evt.getRequest().getRawContent();
if (rawContent == null) {
return null;
}
if (charset == null) { if (charset == null) {
charset = "gb2312"; charset = "gb2312";
} }
Request request = evt.getRequest();
SAXReader reader = new SAXReader(); SAXReader reader = new SAXReader();
reader.setEncoding(charset); reader.setEncoding(charset);
// 对海康出现的未转义字符做处理。 // 对海康出现的未转义字符做处理。
@ -182,10 +186,6 @@ public abstract class SIPRequestProcessorParent {
char despChar = '&'; char despChar = '&';
byte destBye = (byte) despChar; byte destBye = (byte) despChar;
List<Byte> result = new ArrayList<>(); List<Byte> result = new ArrayList<>();
byte[] rawContent = request.getRawContent();
if (rawContent == null) {
return null;
}
for (int i = 0; i < rawContent.length; i++) { for (int i = 0; i < rawContent.length; i++) {
if (rawContent[i] == destBye) { if (rawContent[i] == destBye) {
boolean resul = false; boolean resul = false;

View File

@ -68,6 +68,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme
Element rootElement = getRootElement(evt); Element rootElement = getRootElement(evt);
if (rootElement == null) { if (rootElement == null) {
log.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest()); log.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest());
responseAck(request, Response.BAD_REQUEST);
return; return;
} }
String cmd = XmlUtil.getText(rootElement, "CmdType"); String cmd = XmlUtil.getText(rootElement, "CmdType");

View File

@ -102,11 +102,6 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement
sipEvent.getErrorEvent().response(eventResult); sipEvent.getErrorEvent().response(eventResult);
} }
}else { }else {
byte[] rawContent = request.getRawContent();
if (rawContent == null) {
responseAck(request, Response.BAD_REQUEST, "content is null");
return;
}
Element rootElement; Element rootElement;
try { try {
rootElement = getRootElement(evt); rootElement = getRootElement(evt);