From 56910a0a29243c79a505a279e7d2f69394235546 Mon Sep 17 00:00:00 2001 From: Quan HL Date: Tue, 10 Oct 2023 11:24:17 +0700 Subject: [PATCH] fix outbound info --- lib/call-session.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/call-session.js b/lib/call-session.js index 2bd859e..2403da0 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -861,15 +861,17 @@ Duration=${payload.duration} ` } } else { - const response = await dlg.other.request({ - method: 'INFO', - headers: req.headers, - body: req.body - }); - res.send(response.status, { - headers: response.headers, - body: response.body + const immutableHdrs = ['via', 'from', 'to', 'call-id', 'cseq', 'max-forwards', 'content-length']; + const headers = {}; + Object.keys(req.headers).forEach((h) => { + if (!immutableHdrs.includes(h)) headers[h] = req.headers[h]; }); + const response = await dlg.other.request({method: 'INFO', headers, body: req.body}); + const responseHeaders = {}; + if (response.has('Content-Type')) { + Object.assign(responseHeaders, {'Content-Type': response.get('Content-Type')}); + } + res.send(response.status, {headers: responseHeaders, body: response.body}); } } catch (err) { this.logger.info({err}, `Error handing INFO request on ${dlg.type} leg`);