Closed teerapap closed 4 years ago
Have you looked at some of the examples? I have some basic here: http://www.siplib.io/ and checkout the unit tests in SipResponseTest
and in particular here: https://github.com/aboutsip/pkts/blob/1d72e989b0325b97f06484b28679444ad97a36ee/pkts-sip/src/test/java/io/pkts/packet/sip/SipResponseTest.java#L114
The philosophy around creating a response from a request is slightly different than perhaps what you're used to. The idea is that you often want to copy over various headers as is (all headers are immutable) so when you build a response from a request, you kind of "stream" them over to the response and when that happens you have a chance to either drop them, keep them, or change them. The benefit is that I can under the hood have everything share the same underlying byte-array since, again, everything is immutable.
Hope that answers your question.
Thanks @jonbo372
Problem: I want to replace existing
To:
header. How to do that? It seems theSipMessageBuilder
has not method to do it because thiswithHeader(..)
method adds the input as a new header. The message output results in doubleTo:
header.https://github.com/aboutsip/pkts/blob/1d72e989b0325b97f06484b28679444ad97a36ee/pkts-sip/src/main/java/io/pkts/packet/sip/impl/SipMessageBuilder.java#L220
Example code:
Thanks