drachtio-srf 4.5.27 → 4.5.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/srf.js CHANGED
@@ -871,15 +871,31 @@ class Srf extends Emitter {
871
871
  res.send(500);
872
872
  }
873
873
  else {
874
- req.on('cancel', () => {
874
+ req.on('cancel', (cancelReq) => {
875
875
  debug('createB2BUA: received CANCEL from A party, sending CANCEL to B');
876
876
  res.send(487) ;
877
- uacReq.cancel() ;
877
+ uacReq.cancel({
878
+ headers: copyUASHeaderToUACForOnlyCancel(cancelReq)
879
+ }
880
+ ) ;
878
881
  });
879
882
  }
880
883
  cbRequest(err, uacReq);
881
884
  }
882
885
 
886
+ /* Special for Cancel request, we just forward hardcoded list of headers here*/
887
+ function copyUASHeaderToUACForOnlyCancel(uasReq) {
888
+ const headers = {};
889
+ if (!uasReq) {
890
+ return headers;
891
+ }
892
+
893
+ ['Reason', 'X-Reason']
894
+ .forEach((hdr) => { if (uasReq.has(hdr)) headers[hdr] = uasReq.get(hdr);}) ;
895
+
896
+ return headers ;
897
+ }
898
+
883
899
  /* get headers from response on uac (B) leg and ready them for inclusion on our response on uas (A) leg */
884
900
  function copyUACHeadersToUAS(uacRes) {
885
901
  const headers = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drachtio-srf",
3
- "version": "4.5.27",
3
+ "version": "4.5.28",
4
4
  "description": "drachtio signaling resource framework",
5
5
  "main": "lib/srf.js",
6
6
  "types": "lib/@types/index.d.ts",
package/test/b2b.js CHANGED
@@ -348,4 +348,4 @@ test('B2B', (t) => {
348
348
  if (b2b) b2b.disconnect();
349
349
  t.error(err);
350
350
  });
351
- });
351
+ });
@@ -67,6 +67,7 @@
67
67
  To: [service] <sip:[service]@[remote_ip]:[remote_port]>
68
68
  Call-ID: [call_id]
69
69
  CSeq: 1 CANCEL
70
+ Reason: SIP;cause=200;text="Call completed elsewhere"
70
71
  Content-Length: 0
71
72
 
72
73
  ]]>