PJSIP_HEADER()
Synopsis
Gets headers from an inbound PJSIP channel. Adds, updates or removes the specified SIP header from an outbound PJSIP channel.
Description
PJSIP_HEADER allows you to read specific SIP headers from the inbound PJSIP channel as well as write(add, update, remove) headers on the outbound channel. One exception is that you can read headers that you have already added on the outbound channel.
Examples:
Example: Set somevar to the value of the From header
Example: Set via2 to the value of the 2nd Via header
Example: Set xhdr to the value of the 1st X-header
Example: Add an X-Myheader header with the value of myvalue
Example: Add an X-Myheader header with an empty value
Example: Update the value of the header named X-Myheader to newvalue
Example: Remove all headers whose names exactly match X-MyHeader
Example: Remove all headers that begin with X-My
Example: Remove all previously added headers
Example: Display the number of headers removed
Example: Set a variable to the number of headers removed
Example: Just remove them ignoring any count
Example: Set headers on callee channel
Syntax
PJSIP_HEADER(action,name[,number])
Arguments
action
read
- Returns instance number of header name. A {} may be appended to name to iterate over all headers *beginning with name.add
- Adds a new header name to this session.update
- Updates instance number of header name to a new value. The header must already exist.remove
- Removes all instances of previously added headers whose names match name. A {} may be appended to name to remove all headers *beginning with name. name may be set to a single {} to clear *all previously added headers. In all cases, the number of headers actually removed is returned.
name
- The name of the header.number
- If there's more than 1 header with the same name, this specifies which header to read or update. If not specified, defaults to1
meaning the first matching header. Not valid foradd
orremove
.
See Also
Import Version
This documentation was imported from Asterisk Version GIT-19-6436d82