Home Forums
|
altering header content (0 viewing)
Favoured: 0
|
|
|
TOPIC: altering header content
|
|
|
|
altering header content 1 Year, 1 Month ago
|
|
I need to add NOTIFY to the Allow header of this SUBSCRIBE message. It seems the HeaderAddHelper obj is intended to add user-defined headers. How do I alter the existing Allow header? | Code: : |
5331 [main] INFO KitCAT.SipStack - <message
from="192.168.32.116:23456"
to="172.16.0.28:6060"
time="1248384876764"
isSender="true"
transactionId="z9hg4bkad89bc02a5483339774a3ac804cb2d4f"
callId="
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
"
firstLine="SUBSCRIBE sip:
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
SIP/2.0"
>
<![CDATA[SUBSCRIBE sip:alice@sweng.com SIP/2.0
Call-ID: 6ebaa3bdb2df8c9c47a673d83bc7f423@192.168.32.116
CSeq: 1 SUBSCRIBE
From: "alice" <sip:alice@sweng.com>;tag=aliceSipPort31248384872204
To: <sip:alice@sweng.com>
Via: SIP/2.0/UDP 192.168.32.116:23456;branch=z9hG4bKad89bc02a5483339774a3ac804cb2d4f
Max-Forwards: 70
Contact: <sip:alice@192.168.32.116:23456>
User-Agent: mytest.MyTest.runBeforeEachTest.alice Thu Jul 23 17:34:31 EDT 2009
<strong>Allow: INVITE,BYE,CANCEL,ACK,PRACK,INFO</strong>
Route: <sip:orig@scscf.sweng.com:6060;lr>
Event: message-summary
Expires: 300
Content-Length: 0
]]>
</message>
|
|
|
|
|
|
|
|
The administrator has disabled public write access. |
|
|
|
Re:altering header content 1 Year, 1 Month ago
|
|
Hi Russ, Here is a code snippet that I used recently to modify some message headers. You basically use the MessageModifier class to do this. You can use the addMessageModifier() method on the agent. You have to use the JAIN SIP API to do the actual modification. hope this helps. | Code: : |
MessageModifier myMsgModifier;
void addMsgModifier(SIPAgent agent) throws Exception {
myMsgModifier =
new MessageModifier() {
public void modify(javax.sip.message.Message message) throws Exception {
if (message instanceof javax.sip.message.Request) {
javax.sip.message.Request req = (javax.sip.message.Request) message;
if (req.getMethod().equals("INVITE")) {
javax.sip.SipFactory sipFactory = javax.sip.SipFactory.getInstance();
javax.sip.header.HeaderFactory headerFactory = sipFactory.createHeaderFactory();
message.removeHeader("Allow");
message.addLast(headerFactory.createHeader("Allow", "INVITE"));
message.addLast(headerFactory.createHeader("Allow", "ACK"));
message.addLast(headerFactory.createHeader("Allow", "PRACK"));
message.addLast(headerFactory.createHeader("Allow", "SUBSCRIBE"));
message.addLast(headerFactory.createHeader("Allow", "BYE"));
message.addLast(headerFactory.createHeader("Allow", "CANCEL"));
message.addLast(headerFactory.createHeader("Allow", "NOTIFY"));
message.addLast(headerFactory.createHeader("Allow", "INFO"));
message.addLast(headerFactory.createHeader("Allow", "REFER"));
message.addLast(headerFactory.createHeader("Allow", "UPDATE"));
message.addLast(headerFactory.createHeader("Min-SE", "2147483"));
message.addLast(headerFactory.createHeader("Session-Expires", "2147483"));
message.addLast(headerFactory.createHeader("Supported", "timer"));
}
}
}
};
agent.addMessageModifier(myMsgModifier);
}
void removeMsgModifier(SIPAgent agent) throws Exception {
agent.removeMessageModifier(myMsgModifier);
}
|
|
|
|
|
|
|
|
The administrator has disabled public write access. |
|
|
|
Re:altering header content 1 Year, 1 Month ago
|
|
|
Venkita, Ok, thanks, that works. Actually I'd come across a similar instance of this in the sample code which accompanies the distribution ... but somehow failed to recognize it for what it was. Russ
|
|
|
|
|
|
|
The administrator has disabled public write access. |
|
|
|
|
|