Skip to content

PJSIP_RESPONSE_HEADER()

Synopsis

Gets headers of 200 response from an outbound PJSIP channel.

Description

PJSIP_RESPONSE_HEADER allows you to read specific SIP headers of 200 response from the outbound PJSIP channel.

Examples:

Example: Set 'somevar' to the value of the 'From' header
exten => 1,1,Set(somevar=${PJSIP_RESPONSE_HEADER(read,From)})
Example: Set 'via2' to the value of the 2nd 'Via' header
exten => 1,1,Set(via2=${PJSIP_RESPONSE_HEADER(read,Via,2)})
Example: Set 'xhdr' to the value of the 1sx X-header
exten => 1,1,Set(xhdr=${PJSIP_RESPONSE_HEADER(read,X-*,1)})

Note

If you call PJSIP_RESPONSE_HEADER in a normal dialplan context you'll be operating on the caller's (incoming) channel which may not be what you want. To operate on the callee's (outgoing) channel call PJSIP_RESPONSE_HEADER in a pre-connect handler.

Example: Usage on pre-connect handler
[handler]
exten => readheader,1,NoOp(PJSIP_RESPONSE_HEADER(read,X-MyHeader))
[somecontext]
exten => 1,1,Dial(PJSIP/${EXTEN},,U(handler^readheader^1))

Syntax

PJSIP_RESPONSE_HEADER(action,name[,number])
Arguments
  • action

    • read - Returns instance number of response header name.
  • name - The name of the response header. A '' can be appended to the name to iterate over all response headers *beginning with name.

  • number - If there's more than 1 header with the same name, this specifies which header to read. If not specified, defaults to '1' meaning the first matching header.

See Also

Generated Version

This documentation was generated from Asterisk branch 20 using version GIT