-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
…SAGE Fixed incoming SIP MESSAGE processing when the Content-Type header contains parameters
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,19 +159,38 @@ JsSIP.Message.prototype.close = function() { | |
* @private | ||
*/ | ||
JsSIP.Message.prototype.init_incoming = function(request) { | ||
var contentType = request.getHeader('content-type'); | ||
var transaction, | ||
contentType = request.getHeader('content-type'); | ||
|
||
this.direction = 'incoming'; | ||
this.local_identity = request.s('to').uri; | ||
this.remote_identity = request.s('from').uri; | ||
|
||
request.reply(200, JsSIP.c.REASON_200); | ||
this.accept = function() { | ||
request.reply(200, JsSIP.c.REASON_200); | ||
}; | ||
|
||
if (contentType && contentType === "text/plain") { | ||
this.reject = function(status_code, reason_phrase) { | ||
if (status_code && reason_phrase) { | ||
request.reply(status_code, reason_phrase); | ||
} else { | ||
request.reply(480, JsSIP.c.REASON_480); | ||
} | ||
}; | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jmillan
Author
Member
|
||
if (contentType && (contentType.match(/^text\/plain(\s*;\s*.+)*$/i) || contentType.match(/^text\/html(\s*;\s*.+)*$/i))) { | ||
this.ua.emit('newMessage', this.ua, { | ||
originator: 'remote', | ||
message: this, | ||
request: request | ||
}); | ||
|
||
transaction = this.ua.transactions.nist[request.via_branch]; | ||
|
||
if (transaction && (transaction.state === JsSIP.c.TRANSACTION_TRYING || transaction.state === JsSIP.c.TRANSACTION_PROCEEDING)) { | ||
request.reply(200, JsSIP.c.REASON_200); | ||
This comment has been minimized.
Sorry, something went wrong.
saghul
Contributor
|
||
} | ||
} else { | ||
request.reply(415, JsSIP.c.REASON_415, ["Accept: text/plain, text/html"]); | ||
} | ||
}; |
I don't fully like the above. The user should be allowed to just pass the status code without reason and the above approach does not allow it (which I consider dangerous since it could generate an empty reason in the response or raise some error when converting
null
to string).Proposal (pseudo-code):
I hope this should be the approach in every function allowing passing status and reason as optional params.
BTW: Why aren't those accept() and reject() functions defined as prototype methods?