diff options
Diffstat (limited to 'sip/src/encoding')
-rw-r--r-- | sip/src/encoding/mod.rs | 7 | ||||
-rw-r--r-- | sip/src/encoding/request.rs | 3 |
2 files changed, 9 insertions, 1 deletions
diff --git a/sip/src/encoding/mod.rs b/sip/src/encoding/mod.rs index 816aa01..3c2f3fd 100644 --- a/sip/src/encoding/mod.rs +++ b/sip/src/encoding/mod.rs @@ -1,5 +1,6 @@ use std::{fmt::Display, str::FromStr}; +use headers::ContentLength; use request::Request; use response::Response; @@ -43,4 +44,10 @@ impl Message { Message::Response(r) => &mut r.body, } } + pub fn content_length(&self) -> Option<Result<ContentLength, anyhow::Error>> { + match self { + Message::Request(r) => r.headers.get::<ContentLength>(), + Message::Response(r) => r.headers.get::<ContentLength>(), + } + } } diff --git a/sip/src/encoding/request.rs b/sip/src/encoding/request.rs index ab41b7c..06f9f9d 100644 --- a/sip/src/encoding/request.rs +++ b/sip/src/encoding/request.rs @@ -16,10 +16,11 @@ impl Display for Request { headers, method, uri, - .. + body, } = self; write!(f, "{method} {uri} SIP/2.0\r\n")?; write!(f, "{headers}\r\n")?; + write!(f, "{body}")?; Ok(()) } } |