Skip to content

Commit

Permalink
forward all refer to feature server (#156)
Browse files Browse the repository at this point in the history
* forward all refer to feature server

* forwawrd extra custom header
  • Loading branch information
xquanluu authored Dec 6, 2024
1 parent c6c63e2 commit c762acc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/call-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,19 @@ class CallSession extends Emitter {
async _onRefer(dlg, req, res) {
/* REFER coming in from a sip device, forward to feature server */
try {
const customHeaders = Object.keys(req.headers)
.filter((h) => h.toLowerCase().startsWith('x-'))
.reduce((acc, h) => {
acc[h] = req.get(h);
return acc;
}, {});
const response = await dlg.other.request({
method: 'REFER',
headers: {
'Refer-To': req.get('Refer-To'),
'Referred-By': req.get('Referred-By'),
'User-Agent': req.get('User-Agent')
'User-Agent': req.get('User-Agent'),
...customHeaders
}
});
res.send(response.status, response.reason);
Expand Down

0 comments on commit c762acc

Please sign in to comment.