Skip to content

Commit

Permalink
Merge pull request #11 from rtckit/v0.3.2
Browse files Browse the repository at this point in the history
v0.3.2
  • Loading branch information
cdosoftei authored Jul 28, 2021
2 parents 54af835 + 0309583 commit d0f9a6f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "rtckit/sip",
"description": "Parser/Renderer for SIP protocol written in PHP",
"version": "0.3.1",
"version": "0.3.2",
"type": "library",
"keywords": [
"sip",
Expand Down
26 changes: 25 additions & 1 deletion src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ class Message
'k' => 'supported',
'l' => 'content-length',
'm' => 'contact',
'o' => 'event',
'r' => 'refer-to',
's' => 'subject',
't' => 'to',
'u' => 'allow-events',
'v' => 'via',
];

Expand Down Expand Up @@ -79,6 +81,8 @@ class Message

/* Single value with parameters header fields */
public SingleValueWithParamsHeader $contentType;
public SingleValueWithParamsHeader $event;
public SingleValueWithParamsHeader $subscriptionState;

/* Multiple value header fields */
public MultiValueHeader $acceptEncoding;
Expand Down Expand Up @@ -282,6 +286,18 @@ public static function parse(string $text, bool $ignoreBody = false): Message

continue 2;

/* https://datatracker.ietf.org/doc/html/rfc6665#section-8.2.1 */
case 'event':
$msg->event = SingleValueWithParamsHeader::parse($hbody);

continue 2;

/* https://datatracker.ietf.org/doc/html/rfc6665#section-8.2.3 */
case 'subscription-state':
$msg->subscriptionState = SingleValueWithParamsHeader::parse($hbody);

continue 2;

/* https://tools.ietf.org/html/rfc3261#section-20.2 */
case 'accept-encoding':
$msg->acceptEncoding = MultiValueHeader::parse($hbody);
Expand Down Expand Up @@ -574,6 +590,14 @@ public function renderHeaders(bool $compact): string
$ret .= $this->contentType->render($compact ? 'c' : 'Content-Type');
}

if (isset($this->event)) {
$ret .= $this->event->render($compact ? 'o' : 'Event');
}

if (isset($this->subscriptionState)) {
$ret .= $this->subscriptionState->render('Subscription-State');
}

if (isset($this->acceptEncoding)) {
$ret .= $this->acceptEncoding->render('Accept-Encoding');
}
Expand All @@ -583,7 +607,7 @@ public function renderHeaders(bool $compact): string
}

if (isset($this->allowEvents)) {
$ret .= $this->allowEvents->render('Allow-Events');
$ret .= $this->allowEvents->render($compact ? 'u' : 'Allow-Events');
}

if (isset($this->contentEncoding)) {
Expand Down

0 comments on commit d0f9a6f

Please sign in to comment.