123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Asterisk Project : Asterisk 13 Function_PJSIP_HEADER</title>
- <link rel="stylesheet" href="styles/site.css" type="text/css" />
- <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
- </head>
- <body class="theme-default aui-theme-default">
- <div id="page">
- <div id="main" class="aui-page-panel">
- <div id="main-header">
- <div id="breadcrumb-section">
- <ol id="breadcrumbs">
- <li class="first">
- <span><a href="index.html">Asterisk Project</a></span>
- </li>
- <li>
- <span><a href="Asterisk-13-Command-Reference_29394274.html">Asterisk 13 Command Reference</a></span>
- </li>
- <li>
- <span><a href="Asterisk-13-Dialplan-Functions_29394287.html">Asterisk 13 Dialplan Functions</a></span>
- </li>
- </ol>
- </div>
- <h1 id="title-heading" class="pagetitle">
- <span id="title-text">
- Asterisk Project : Asterisk 13 Function_PJSIP_HEADER
- </span>
- </h1>
- </div>
- <div id="content" class="view">
- <div class="page-metadata">
-
-
-
-
-
-
-
- Created by <span class='author'> wikibot</span> on Aug 08, 2014
- </div>
- <div id="main-content" class="wiki-content group">
- <h1 id="Asterisk13Function_PJSIP_HEADER-PJSIP_HEADER()">PJSIP_HEADER()</h1>
- <h3 id="Asterisk13Function_PJSIP_HEADER-Synopsis">Synopsis</h3>
- <p>Gets, adds, updates or removes the specified SIP header from a PJSIP session.</p>
- <h3 id="Asterisk13Function_PJSIP_HEADER-Description">Description</h3>
- <p>Examples:</p>
- <p>;</p>
- <p>; Set 'somevar' to the value of the 'From' header.</p>
- <p>exten => 1,1,Set(somevar=${PJSIP_HEADER(read,From)})</p>
- <p>;</p>
- <p>; Set 'via2' to the value of the 2nd 'Via' header.</p>
- <p>exten => 1,1,Set(via2=${PJSIP_HEADER(read,Via,2)})</p>
- <p>;</p>
- <p>; Add an 'X-Myheader' header with the value of 'myvalue'.</p>
- <p>exten => 1,1,Set(PJSIP_HEADER(add,X-MyHeader)=myvalue)</p>
- <p>;</p>
- <p>; Add an 'X-Myheader' header with an empty value.</p>
- <p>exten => 1,1,Set(PJSIP_HEADER(add,X-MyHeader)=)</p>
- <p>;</p>
- <p>; Update the value of the header named 'X-Myheader' to 'newvalue'.</p>
- <p>; 'X-Myheader' must already exist or the call will fail.</p>
- <p>exten => 1,1,Set(PJSIP_HEADER(update,X-MyHeader)=newvalue)</p>
- <p>;</p>
- <p>; Remove all headers whose names exactly match 'X-MyHeader'.</p>
- <p>exten => 1,1,Set(PJSIP_HEADER(remove,X-MyHeader)=)</p>
- <p>;</p>
- <p>; Remove all headers that begin with 'X-My'.</p>
- <p>exten => 1,1,Set(PJSIP_HEADER(remove,X-My*)=)</p>
- <p>;</p>
- <p>; Remove all previously added headers.</p>
- <p>exten => 1,1,Set(PJSIP_HEADER(remove,*)=)</p>
- <p>;</p>
- <div class="aui-message hint shadowed information-macro">
- <p class="title">Note</p>
- <span class="aui-icon icon-hint">Icon</span>
- <div class="message-content">
-
- <p>The <code>remove</code> action can be called by reading <strong>or</strong> writing PJSIP_HEADER.</p>
- <p>;</p>
- <p>; Display the number of headers removed</p>
- <p>exten => 1,1,Verbose( Removed ${PJSIP_HEADER(remove,X-MyHeader)} headers)</p>
- <p>;</p>
- <p>; Set a variable to the number of headers removed</p>
- <p>exten => 1,1,Set(count=${PJSIP_HEADER(remove,X-MyHeader)})</p>
- <p>;</p>
- <p>; Just remove them ignoring any count</p>
- <p>exten => 1,1,Set(=${PJSIP_HEADER(remove,X-MyHeader)})</p>
- <p>exten => 1,1,Set(PJSIP_HEADER(remove,X-MyHeader)=)</p>
- <p>;</p>
- </div>
- </div>
- <div class="aui-message hint shadowed information-macro">
- <p class="title">Note</p>
- <span class="aui-icon icon-hint">Icon</span>
- <div class="message-content">
-
- <p>If you call PJSIP_HEADER in a normal dialplan context you'll be operating on the <strong>caller's (incoming)</strong> channel which may not be what you want. To operate on the <strong>callee's (outgoing)</strong> channel call PJSIP_HEADER in a pre-dial handler.</p>
- <p>Example:</p>
- <p>;</p>
- <p>[handler]</p>
- <p>exten => addheader,1,Set(PJSIP_HEADER(add,X-MyHeader)=myvalue)</p>
- <p>exten => addheader,2,Set(PJSIP_HEADER(add,X-MyHeader2)=myvalue2)</p>
- <p>;</p>
- <p>[somecontext]</p>
- <p>exten => 1,1,Dial(PJSIP/${EXTEN},,b(handler^addheader^1))</p>
- <p>;</p>
- </div>
- </div>
- <h3 id="Asterisk13Function_PJSIP_HEADER-Syntax">Syntax</h3>
- <div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
- <pre>PJSIP_HEADER(action,name[,number])</pre>
- </div></div>
- <h5 id="Asterisk13Function_PJSIP_HEADER-Arguments">Arguments</h5>
- <ul>
- <li><code>action</code>
- <ul>
- <li><code>read</code> - Returns instance <em>number</em> of header <em>name</em>.</li>
- <li><code>add</code> - Adds a new header <em>name</em> to this session.</li>
- <li><code>update</code> - Updates instance <em>number</em> of header <em>name</em> to a new value. The header must already exist.</li>
- <li><code>remove</code> - Removes all instances of previously added headers whose names match <em>name</em>. A {<strong>} may be appended to <em>name</em> to remove all headers *beginning with</strong> <em>name</em>. <em>name</em> may be set to a single {<strong>} to clear *all</strong> previously added headers. In all cases, the number of headers actually removed is returned.</li>
- </ul>
- </li>
- <li><code>name</code> - The name of the header.</li>
- <li><code>number</code> - If there's more than 1 header with the same name, this specifies which header to read or update. If not specified, defaults to <code>1</code> meaning the first matching header. Not valid for <code>add</code> or <code>remove</code>.</li>
- </ul>
- <h3 id="Asterisk13Function_PJSIP_HEADER-SeeAlso">See Also</h3>
- <h3 id="Asterisk13Function_PJSIP_HEADER-ImportVersion">Import Version</h3>
- <p>This documentation was imported from Asterisk Version SVN-branch-13-r420538</p>
- </div>
-
-
- </div> </div>
- <div id="footer">
- <section class="footer-body">
- <p>Document generated by Confluence on Aug 11, 2014 13:47</p>
- </section>
- </div>
- </div> </body>
- </html>
|