-
-
Notifications
You must be signed in to change notification settings - Fork 89
Using Content-Length to determine SIP message size #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
it's RFC RFC3261 not RFC3162 |
furthermore, the SIP decoder works regardless of transport layer protocol. but the mandate of content-length is only for TCP not UDP. |
While that is true the RFC also states:
Could it not then be argued that if the header is there, it should be used? |
to determine message-size when transporting SIP over TCP. The Content-Length header is utilized to determine the payload size if it is present, otherwise payload size will be determined by the size of the buffer being parsed. The setTruncated flag will also be set during parsing if the buffer being parsed does not contain enough data, to honor the Content-Length header.
96cadf7
to
7ea3e2d
Compare
will this break any TCP SIP that doesn't have the content-length header? at the very least there must be some tests for that scenario. I'm reluctant to merge anything breaking especially when it's a "should" in RFC not a MUST |
That makes total sense, they way it has been implemented, it SHOULD not change current behavior if the header is not there, but I will add tests to ensure this fact. |
To ensure backwards compatibility, get .GetContentLength() method will no longer return the actual size of the payload, but ONLY reflect the content of the "Content-Length" header, and returning 0 if the header is not set. Also updated tests to ensure the above.
On second thought .. the RFC does state that the "Content-Length" header MUST be used when on protocols like TCP
But as tests currently does not cover decoding any requests without the "Content-Length" header, I will add this, also I will ensure the behavior of the |
This test will show that length of the message body is only limited if the Content-Length header is present.
I added one more test to show that length of the message body is only limited when the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good now. thanks for your patience. will merge.
As stated in "RFC3261 - 20.14 Content-Length" the header must be used to determine message-size when transporting SIP over TCP.
The Content-Length header is utilized to determine the payload size if it is present, otherwise payload size will be determined by the size of the buffer being parsed.
The setTruncated flag will also be set during parsing if the buffer being parsed does not contain enough data, to honor the Content-Length header.