< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index  

Re: [reSIProcate] Does there have a common way to got RFC headers value and extension headers value ?


Thank you Byron, I have checked the HeaderHash class, but I do not know how to use for me.
And do not found any example on the reSIProcate source code and with and mailist.
 
Can you please give me tips?
 
thanks

 
2008/3/25, Byron Campen <bcampen@xxxxxxxxxxxx>:
Doing this would be tricky. It would probably involve leaning on HeaderHash::in_word_set() (this will map a string to a header-type) and a very large switch statement on the header-type. This would be time-consuming to say the least, and prone to breakage if new header-types are added.
 

 
Best regards,
Byron Campen

Thank you Byron, but as my function, the user call this function and passed the headerName as parameter,
I do not know the header is built-in header or is extension header, so I want to found common way.
 
I just think a stupid idea, use the case to mapping headerName parameter with the buit-in headers.
 
void GetHeaderValue(Data buff, string headerName)
{
 SipMessage * message = SipMessage::make(buff);
 if (!message)
 {
  return ;
 }
 
case h_to:
   compare headerName with "to"
   break
 
case h_from:
    compare headerName with "to"
   break
 
default:
    it's extension header. 
  break

 ExtensionHeader h_Extension(headerName.c_str());
 if (message->exists(h_Extension) == false)
 {
  return ;
 }


 if (message->header(h_Extension).empty() == true)
 {
  return ;
 }


 if (message->header(h_Extension).front().isWellFormed() == false)
 {
  return ;
 }

 Data temp(message->header(h_Extension).front().value());

}
 
But this is not pretty.


 
2008/3/25, Byron Campen <bcampen@xxxxxxxxxxxx>:
       You don't access the headers with built-in support with
ExtensionHeader. You need to use the already-defined header access
tokens. (see http://www.resiprocate.org/Use_Overview#Headers)

Best regards,
Byron Campen


> Hi, I want to write a function to got the headers value. it's
> working fine with Extension header, but for the
> RFC header, likes contact, to, from. I got assert error,.
> How to mofify this function then it can be working with
> RFC headers and extension headers both?
>
> Thank you in advance.
>
>
> void GetHeaderValue(Data buff, string headerName)
> {
>  SipMessage * message = SipMessage::make(buff);
>  if (!message)
>  {
>   return ;
>  }
>  ExtensionHeader h_Extension(headerName.c_str());
>  if (message->exists(h_Extension) == false)
>  {
>   return ;
>  }
>
>
>  if (message->header(h_Extension).empty() == true)
>  {
>   return ;
>  }
>
>
>  if (message->header(h_Extension).front().isWellFormed() == false)
>  {
>   return ;
>  }
>
>  Data temp(message->header(h_Extension).front().value());
>
>
>
> }
> _______________________________________________
> resiprocate-devel mailing list
> resiprocate-devel@xxxxxxxxxxxxxxx
> https://list.resiprocate.org/mailman/listinfo/resiprocate-devel