Response 补充 user-agent

This commit is contained in:
shikong 2023-09-26 17:14:41 +08:00
parent 296747ec31
commit 74cd2d2048
2 changed files with 7 additions and 0 deletions

View File

@ -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<ViaHeader> 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 <T> 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 <T> 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 <T> 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);
}
}

View File

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