From: Richard Whitehouse Date: Sun, 29 Oct 2017 17:29:23 +0000 (+0000) Subject: Support Error-Info header X-Git-Url: https://git.richardwhiuk.com/?a=commitdiff_plain;h=4bbc93596f3525e5a3de9790346921824fda6a68;p=rust-sip.git Support Error-Info header --- diff --git a/src/codec.rs b/src/codec.rs index c873c51..1e0b011 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -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:\r\nVia: \ + localhost\r\n\r\n") }); let finished = request.and_then(|(socket, _request)| { diff --git a/src/parser.rs b/src/parser.rs index 6adbb5e..f2f2367 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -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, preceded!( tag!(b"Date:"), date_time)); +named!(error_uri, tuple!( + delimited!( + tag!(b"<"), + absolute_uri, + tag!(b">") + ), + many0!(preceded!( + tag!(b";"), + generic_param)))); + +named!(error_info_header>, preceded!( + tag!(b"Error-Info:"), + separated_nonempty_list!( + tag!(","), + error_uri))); + named!(pub header
, alt!( // RFC 3261 Headers accept_header => { |a| Header::Accept(a) } | @@ -900,5 +916,6 @@ named!(pub 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) } )); diff --git a/src/types.rs b/src/types.rs index 3276ed2..43243d9 100644 --- a/src/types.rs +++ b/src/types.rs @@ -331,6 +331,8 @@ pub type Time = (u8, u8, u8); pub type DateTime = (Day, Date, Time); +pub type ErrorUri = (AbsoluteUri, Vec); + #[derive(Debug)] pub enum Header { Accept(Vec), @@ -350,6 +352,7 @@ pub enum Header { ContentType(MediaType), CSeq(u32, Method), Date(DateTime), + ErrorInfo(Vec), From(Uri), To(Uri), Extension { name: String, value: String },