Skip to content

Commit

Permalink
forwawrd extra custom header
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu committed Nov 25, 2024
1 parent dd4a91f commit da4410e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/call-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -781,9 +781,20 @@ 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: req.headers
headers: {
'Refer-To': req.get('Refer-To'),
'Referred-By': req.get('Referred-By'),
'User-Agent': req.get('User-Agent'),
...customHeaders
}
});
res.send(response.status, response.reason);
} catch (err) {
Expand Down

0 comments on commit da4410e

Please sign in to comment.