Support Error-Info header
authorRichard Whitehouse <github@richardwhiuk.com>
Sun, 29 Oct 2017 17:29:23 +0000 (17:29 +0000)
committerRichard Whitehouse <github@richardwhiuk.com>
Sun, 29 Oct 2017 17:29:23 +0000 (17:29 +0000)
src/codec.rs
src/parser.rs
src/types.rs

index c873c51a1fbb574777263937676c4a12bac52f7e..1e0b01143096d76f73ca6637574751fe1228d6c6 100644 (file)
@@ -435,7 +435,9 @@ mod tests {
                            purpose=icon\r\nContact:*\r\nContent-Disposition:\
                            session\r\nContent-Encoding:gzip\r\nContent-Language:\
                            en-gb\r\nContent-Length:0\r\nContent-Type:text/plain\r\nCSeq:1 \
-                           MESSAGE\r\nDate:Sat, 13 Nov 2010 23:29:00 GMT\r\nVia: localhost\r\n\r\n")
+                           MESSAGE\r\nDate:Sat, 13 Nov 2010 23:29:00 \
+                           GMT\r\nError-Info:<sip:not-in-service-recording@atlanta.com>\r\nVia: \
+                           localhost\r\n\r\n")
         });
 
         let finished = request.and_then(|(socket, _request)| {
index 6adbb5ed51491da9fffb89d791869d39a471f913..f2f23677b70e3e732f3277d54bc42ef5c2095cbf 100644 (file)
@@ -16,7 +16,7 @@ use types::{PathSegment, HostPort, Host, Hostname, UriParameter, UriHeader, UriH
             Language, AlertParam, Qop, AuthenticationInfo, AuthParam, Algorithm, DigestResponse,
             Credentials, CallId, Purpose, InfoParam, Info, NameAddr, ContactParam, ContactTarget,
             Contact, DispositionType, Handling, DispositionParam, ContentCoding, Day, Month, Date,
-            Time, DateTime};
+            Time, DateTime, ErrorUri};
 
 fn is_mark(c: u8) -> bool {
     c == b'-' || c == b'_' || c == b'.' || c == b'!' || c == b'~' || c == b'*' || c == b'\'' ||
@@ -882,6 +882,22 @@ named!(date_header<DateTime>, preceded!(
        tag!(b"Date:"),
        date_time));
 
+named!(error_uri<ErrorUri>, tuple!(
+       delimited!(
+               tag!(b"<"),
+               absolute_uri,
+               tag!(b">")
+       ),
+       many0!(preceded!(
+               tag!(b";"),
+               generic_param))));
+
+named!(error_info_header<Vec<ErrorUri>>, preceded!(
+       tag!(b"Error-Info:"),
+       separated_nonempty_list!(
+               tag!(","),
+               error_uri)));
+
 named!(pub header<Header>, alt!(
 // RFC 3261 Headers
        accept_header => { |a| Header::Accept(a) } |
@@ -900,5 +916,6 @@ named!(pub header<Header>, alt!(
        content_length_header => { |l| Header::ContentLength(l) } |
        content_type_header => { |t| Header::ContentType(t) } |
        cseq_header => { |(c, m)| Header::CSeq(c, m) } |
-       date_header => { |d| Header::Date(d) }
+       date_header => { |d| Header::Date(d) } |
+       error_info_header => { |e| Header::ErrorInfo(e) }
 ));
index 3276ed27c37c9264f71be4be3e58cd985b657e3e..43243d9a1233aadeeb1cb9aac4e4b50a710e9803 100644 (file)
@@ -331,6 +331,8 @@ pub type Time = (u8, u8, u8);
 
 pub type DateTime = (Day, Date, Time);
 
+pub type ErrorUri = (AbsoluteUri, Vec<GenericParam>);
+
 #[derive(Debug)]
 pub enum Header {
     Accept(Vec<AcceptRange>),
@@ -350,6 +352,7 @@ pub enum Header {
     ContentType(MediaType),
     CSeq(u32, Method),
     Date(DateTime),
+    ErrorInfo(Vec<ErrorUri>),
     From(Uri),
     To(Uri),
     Extension { name: String, value: String },