兼容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 {
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<Byte> 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;

View File

@ -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");

View File

@ -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);