function 'PJSIP_HEADER'

Gets, adds, updates or removes the specified SIP header from a PJSIP session.

[Description]
Examples:
;
; Set 'somevar' to the value of the 'From' header.
exten => 1,1,Set(somevar=${PJSIP_HEADER(read,From)})
;
; Set 'via2' to the value of the 2nd 'Via' header.
exten => 1,1,Set(via2=${PJSIP_HEADER(read,Via,2)})
;
; Add an 'X-Myheader' header with the value of 'myvalue'.
exten => 1,1,Set(PJSIP_HEADER(add,X-MyHeader)=myvalue)
;
; Add an 'X-Myheader' header with an empty value.
exten => 1,1,Set(PJSIP_HEADER(add,X-MyHeader)=)
;
; Update the value of the header named 'X-Myheader' to 'newvalue'.
; 'X-Myheader' must already exist or the call will fail.
exten => 1,1,Set(PJSIP_HEADER(update,X-MyHeader)=newvalue)
;
; Remove all headers whose names exactly match 'X-MyHeader'.
exten => 1,1,Set(PJSIP_HEADER(remove,X-MyHeader)=)
;
; Remove all headers that begin with 'X-My'.
exten => 1,1,Set(PJSIP_HEADER(remove,X-My*)=)
;
; Remove all previously added headers.
exten => 1,1,Set(PJSIP_HEADER(remove,*)=)
;
NOTE: The 'remove' action can be called by reading *or* writing PJSIP_HEADER.
;
; Display the number of headers removed
exten => 1,1,Verbose( Removed ${PJSIP_HEADER(remove,X-MyHeader)} headers)
;
; Set a variable to the number of headers removed
exten => 1,1,Set(count=${PJSIP_HEADER(remove,X-MyHeader)})
;
; Just remove them ignoring any count
exten => 1,1,Set(=${PJSIP_HEADER(remove,X-MyHeader)})
exten => 1,1,Set(PJSIP_HEADER(remove,X-MyHeader)=)
;
NOTE: If you call PJSIP_HEADER in a normal dialplan context youll be
operating on the *callers (incoming)* channel which may not be what you want.
To operate on the *callees (outgoing)* channel call PJSIP_HEADER in a pre-dial
handler.
Example:
;
[handler]
exten => addheader,1,Set(PJSIP_HEADER(add,X-MyHeader)=myvalue)
exten => addheader,2,Set(PJSIP_HEADER(add,X-MyHeader2)=myvalue2)
;
[somecontext]
exten => 1,1,Dial(PJSIP/${EXTEN},,b(handler^addheader^1))
;
 
[Syntax]
PJSIP_HEADER(action,name[,number])
 
[Arguments]
action
    read - Returns instance <number> of header <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 theres more than 1 header with the same name, this specifies
    which header to read or update.  If not specified, defaults to '1' meaning
    the first matching header.  Not valid for 'add' or 'remove'.

[See Also] Not available

Asterisk: функции диалплана

  • asterisk/func/pjsip_header.txt
  • Последние изменения: 2017/04/06