From: Richard Whitehouse Date: Sun, 29 Oct 2017 20:56:58 +0000 (+0000) Subject: Support Reply-To header X-Git-Url: https://git.richardwhiuk.com/?a=commitdiff_plain;h=8614c76df9dbc2cc18eac96cd81a981516bcdce4;p=rust-sip.git Support Reply-To header --- diff --git a/src/codec.rs b/src/codec.rs index c28439b..f6c4ab9 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -443,7 +443,7 @@ mod tests { 30\r\nOrganization:Foobar\r\nPriority:normal\r\nProxy-Authenticate:\ Digest realm=\"atlanta.com\"\r\nProxy-Authorization:Digest \ username=\"Bob\"\r\nProxy-Require:foo\r\nRecord-Route:\r\nVia: localhost\r\n\r\n") + biloxi.com;lr>\r\nReply-To:\r\nVia: localhost\r\n\r\n") }); let finished = request.and_then(|(socket, _request)| { diff --git a/src/lib.rs b/src/lib.rs index 974d78e..5418383 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,5 @@ +#![recursion_limit="128"] + extern crate futures; extern crate tokio_core; extern crate tokio_io; diff --git a/src/parser.rs b/src/parser.rs index 45dc9ef..f36c8cc 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -17,7 +17,7 @@ use types::{PathSegment, HostPort, Host, Hostname, UriParameter, UriHeader, UriH Credentials, CallId, Purpose, InfoParam, Info, NameAddr, ContactParam, Target, Contact, DispositionType, Handling, DispositionParam, ContentCoding, Day, Month, Date, Time, DateTime, ErrorUri, FromParam, From, Priority, Domain, DigestChallenge, - Challenge, OptionTag, Route}; + Challenge, OptionTag, Route, ReplyTo}; fn is_mark(c: u8) -> bool { c == b'-' || c == b'_' || c == b'.' || c == b'!' || c == b'~' || c == b'*' || c == b'\'' || @@ -1055,6 +1055,18 @@ named!(record_route_header>, preceded!( tag!(b","), route))); +named!(reply_to, pair!( + target, + many0!(preceded!( + tag!(b";"), + generic_param)))); + +named!(reply_to_header>, preceded!( + tag!(b"Reply-To:"), + separated_nonempty_list!( + tag!(b","), + reply_to))); + named!(pub header
, alt!( // RFC 3261 Headers accept_header => { |a| Header::Accept(a) } | @@ -1086,5 +1098,6 @@ named!(pub header
, alt!( proxy_authenticate_header => { |p| Header::ProxyAuthenticate(p) } | proxy_authorization_header => { |p| Header::ProxyAuthorization(p) } | proxy_require_header => { |p| Header::ProxyRequire(p) } | - record_route_header => { |r| Header::RecordRoute(r) } + record_route_header => { |r| Header::RecordRoute(r) } | + reply_to_header => { |r| Header::ReplyTo(r) } )); diff --git a/src/types.rs b/src/types.rs index 2b4a2a1..f2c3eb9 100644 --- a/src/types.rs +++ b/src/types.rs @@ -377,6 +377,8 @@ pub type OptionTag = Vec; pub type Route = (NameAddr, Vec); +pub type ReplyTo = (Target, Vec); + #[derive(Debug)] pub enum Header { Accept(Vec), @@ -409,6 +411,7 @@ pub enum Header { ProxyAuthorization(Credentials), ProxyRequire(Vec), RecordRoute(Vec), + ReplyTo(Vec), To(Uri), Extension { name: String, value: String }, }