forked from drachtio/drachtio-sip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for issue drachtio/drachtio-srf#122
- Loading branch information
1 parent
e573d9f
commit 0c301ed
Showing
2 changed files
with
22 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,18 @@ var parser = require('..').parser ; | |
var parseUri = require('..').parser.parseUri ; | ||
var debug = require('debug')('drachtio-sip') ; | ||
|
||
var optionsMsg = 'OPTIONS sip:[email protected] SIP/2.0\r\n' + | ||
'Via: SIP/2.0/UDP 192.241.212.6:56500;branch=nGTWdf.1124599842;rport;alias\r\n' + | ||
'From: sip:[email protected]:56500;tag=71186921\r\n' + | ||
'To: sip:[email protected]\r\n' + | ||
'Call-ID: [email protected]\r\n' + | ||
'CSeq: 1 OPTIONS\r\n' + | ||
'Contact: sip:[email protected]:56500\r\n' + | ||
'Content-Length: 0\r\n' + | ||
'Max-Forwards: 20\r\n' + | ||
'User-Agent: wFkdhplQ\r\n' + | ||
'Accept: text/plain\r\n'; | ||
|
||
describe('Parser', function(){ | ||
it('should provide headers as string values', function(){ | ||
var msg = new SipMessage(examples('invite')) ; | ||
|
@@ -14,7 +26,7 @@ describe('Parser', function(){ | |
it('should optionally provide a parsed header', function(){ | ||
var msg = new SipMessage(examples('invite')) ; | ||
var obj = msg.getParsedHeader('from') ; | ||
obj.should.be.type('object'); | ||
obj.should.be.type('object'); | ||
obj.should.have.property('uri') ; | ||
}) ; | ||
|
||
|
@@ -102,24 +114,24 @@ describe('Parser', function(){ | |
uri.family.should.eql('ipv6'); | ||
uri.host.should.eql('[2601:182:cd00:d4c6:604b:16f1:3f5a:44f8]') ; | ||
uri.port.should.eql(61219); | ||
}) ; | ||
}) ; | ||
it('should parse a sip uri with a dash or underscore', function(){ | ||
var uri = parseUri('sip:[email protected]') ; | ||
uri.family.should.eql('ipv4'); | ||
uri.host.should.eql('cor10-san.sip.phone.com') ; | ||
uri.user.should.eql('116751x0'); | ||
}) ; | ||
}) ; | ||
it('should parse a sips uri', function(){ | ||
var uri = parseUri('sips:[email protected]') ; | ||
uri.family.should.eql('ipv4'); | ||
uri.host.should.eql('cor10-san.sip.phone.com') ; | ||
uri.user.should.eql('116751x0'); | ||
uri.scheme.should.eql('sips'); | ||
}) ; | ||
}) ; | ||
it('should parse a multi-part header', function(){ | ||
var msg = new SipMessage(examples('siprec')) ; | ||
msg.payload.length.should.eql(2); | ||
}) ; | ||
}) ; | ||
it('should parse a multi-part header with whitespace before boundary', function(){ | ||
var msg = new SipMessage(examples('siprec2')) ; | ||
msg.payload.length.should.eql(2); | ||
|
@@ -139,5 +151,9 @@ describe('Parser', function(){ | |
msg.get('From').should.eql('"Dave" <sip:daveh@localhost>;tag=1234') ; | ||
msg.callingName.should.eql('Dave'); | ||
}) ; | ||
it('should parse request with carriage return on last line', function(){ | ||
var msg = new SipMessage(optionsMsg) ; | ||
(typeof msg.get('from')).should.eql('string') ; | ||
}) ; | ||
}) ; | ||
|