From 74cd2d2048774f4d53b5f573257ec5721c645959 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Tue, 26 Sep 2023 17:14:41 +0800 Subject: [PATCH] =?UTF-8?q?Response=20=E8=A1=A5=E5=85=85=20user-agent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docking/gb28181/sip/generic/SipResponseBuilder.java | 5 +++++ .../cn/skcks/docking/gb28181/sip/process/RequestTest.java | 2 ++ 2 files changed, 7 insertions(+) diff --git a/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/generic/SipResponseBuilder.java b/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/generic/SipResponseBuilder.java index b8aa09f..0be5087 100644 --- a/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/generic/SipResponseBuilder.java +++ b/gb28181-sip/src/main/java/cn/skcks/docking/gb28181/sip/generic/SipResponseBuilder.java @@ -15,6 +15,7 @@ public class SipResponseBuilder { public static Response createResponse(int statusCode, Request request) { return SipBuilder.addHeaders( SipBuilder.getMessageFactory().createResponse(statusCode, request), + SipBuilder.userAgentHeader, GB_VERSION); } @@ -23,6 +24,7 @@ public class SipResponseBuilder { FromHeader from, ToHeader to, List via, MaxForwardsHeader maxForwards) { return SipBuilder.addHeaders( SipBuilder.getMessageFactory().createResponse(statusCode, callId, cSeq, from, to, via, maxForwards), + SipBuilder.userAgentHeader, GB_VERSION); } @@ -30,6 +32,7 @@ public class SipResponseBuilder { public static Response createResponse(int statusCode, Request request, ContentTypeHeader contentType, T content) { return SipBuilder.addHeaders( SipBuilder.getMessageFactory().createResponse(statusCode, request, contentType, content), + SipBuilder.userAgentHeader, GB_VERSION ); } @@ -38,6 +41,7 @@ public class SipResponseBuilder { public static Response createXmlResponse(int statusCode, Request request, T content) { return SipBuilder.addHeaders( SipBuilder.getMessageFactory().createResponse(statusCode, request, SipContentType.XML, content), + SipBuilder.userAgentHeader, GB_VERSION ); } @@ -46,6 +50,7 @@ public class SipResponseBuilder { public static Response createXmlResponse(int statusCode, Request request, T content, String charset) { return SipBuilder.addHeaders( SipBuilder.getMessageFactory(charset).createResponse(statusCode, request, SipContentType.XML, content), + SipBuilder.userAgentHeader, GB_VERSION); } } diff --git a/gb28181-sip/src/test/java/cn/skcks/docking/gb28181/sip/process/RequestTest.java b/gb28181-sip/src/test/java/cn/skcks/docking/gb28181/sip/process/RequestTest.java index 2c43b07..cb8aab1 100644 --- a/gb28181-sip/src/test/java/cn/skcks/docking/gb28181/sip/process/RequestTest.java +++ b/gb28181-sip/src/test/java/cn/skcks/docking/gb28181/sip/process/RequestTest.java @@ -3,6 +3,7 @@ package cn.skcks.docking.gb28181.sip.process; import cn.hutool.core.util.IdUtil; import cn.skcks.docking.gb28181.sip.method.register.request.RegisterRequestBuilder; import cn.skcks.docking.gb28181.sip.method.register.response.RegisterResponseBuilder; +import cn.skcks.docking.gb28181.sip.utils.SipUtil; import gov.nist.javax.sip.message.SIPResponse; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @@ -28,6 +29,7 @@ public class RequestTest { @Test @SneakyThrows void test() { + SipUtil.setUserAgentVersion("0.1.0"); String callId = IdUtil.fastSimpleUUID(); RegisterRequestBuilder registerRequestBuilder = RegisterRequestBuilder.builder() .localIp(localIp)