< Previous by Date | Date Index | Next by Date > |
Thread Index |
Hi, I’m trying to get the value of headers from my SIP message at run time based on the name of the header. An example for my code is below and it was basically taken from an earlier mailing list post string header = “Call-ID”; // this could be anything Call-ID is just an example resip::Headers::Type headerType = resip::Headers::getType(header.c_str(), header.size()); if(headerType != resip::Headers::UNKNOWN) { const resip::HeaderFieldValueList* hfv = message->getRawHeader(headerType); if(hfv && !hfv->empty()) { string tmp(hfv->front()->getBuffer(), hfv->front()->getLength()); REL_ARCH_TRACE(("header is [%s]", tmp.c_str())); } else { REL_ARCH_TRACE(("[%s] not found and not required", it->second.header.c_str())); } } else { resip::ExtensionHeader exHeader(header.c_str()); if(message->exists(exHeader)) { string tmp = message->header(exHeader).front().value().c_str(); REL_ARCH_TRACE(("ex header is [%s]", tmp.c_str()));); } else { REL_ARCH_TRACE(("[%s] not found and not required", it->second.header.c_str())); } } I have 2 cases where I use this. 1.
One where I have a SIP Message that is stored in our database as a string. I read this back an parse it into a new SipMessage like String message = “REGISTER …………………………. resip::Data tmp = message.c_str(); _sip_message.reset(resip::SipMessage::make(tmp, true)); 2.
Where I clone the message that comes up to my application through DUM and pass that to the above code boost::shared_ptr<resip::SipMessage> requestMessage(dynamic_cast<resip::SipMessage*>(message.clone())); When I do the first one, parsing from a string, my code above works and I can get any known header by using the getRawHeader() function and also any unknown header by using the extension header method. However, when I do the second clone method, I can only get an extension header. When I attempt to get a header using the RawHeader value the HeaderFieldValueList is returned and is not NULL but the list is empty, even though the header
exists in the message. I have confirmed that the message is cloned correctly and can get the header if I used the normal header(h_CallId) style method. Do you know of any reason why this would be? And if there is any other method of getting a known header by its string representation? Thom Accuris Networks is a Private Limited Company registered in the Republic of Ireland. This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. |